In the previous post we cobbled together an SDL2 project in Xcode 9. We have a very simple program that starts up, initialises the SDL2 framework and then shuts down. This gets us over the initial hurdle of setting up a game project but we are still along way off from having a working game. In this second part, I will be writing a simple game loop using SDL2. If you don’t know what a game loop is, or need a refresher, go ahead and read about it in Game Programming Patterns. The game loop is an important foundation of any game engine and its important to get right. I plan to develop this over two articles, in the first (This one) we’ll get the basic loop in place. Then in part 2, we’ll refactor the basic loop into something more maintainable. Anyway, without further ado, let’s get started.
I’ve put together a couple of side projects with SDL2 over the years. I like the library because of it’s simplicity and how it provides a quick way to throw together a cross platform project. This post is a reasonably comprehensive guide to how I set up an Xcode 9 project that links to the latest SDL2 framework. There are other ways to do it, but this is mine.
In a previous post I talked about how I setup a Ubuntu server using LXC on my QNAP NAS server. The plan was to host a small web application I am developing using the Go programming language. In this post I’m going to outline the steps I used to install Go on my server but these same steps should apply to any Ubuntu system. Of course you can use the official installation instructions on the Getting Started page. These steps include some extra detail for those of you running on bare bones installation over ssh, so if the official instructions aren’t working, maybe these can help.
For a new project I am writing a small web application in the Go language. From the off I wanted to have a server setup to host the application so I can more easily test everything out. Being something of a DIY tech head I thought I’d use my QNAP NAS system to run the server since the hardware mostly just hosts my Time Machine backups at the minute and not much else.
QNAP has an application called Container Station which provides an easy way to setup web applications through Docker or run Linux instances with LXC. I’ve previously used this to setup a CouchDB instance with Docker so I decided to install Ubuntu as an LXC container to see if I could get it to run my web server.
I hit an annoying auto-layout issue when working on a client project recently. I was attempting to upgrade the software from the 10.11 to the 10.12 SDK. We had a few compiler issues which were quickly resolved but when I ran the software the document view completely missing from its windows.
The view uses intrinsicContentSize to dynamically size itself inside an NSScrollView based on the document contents and zoom level. We also use a custom NSClipView subclass to centre the view when the scrollview is larger than it. This has worked fine for the last few years, however now my intrinsicContentSize override was not being called and the view was being positioned outside of the clipview bounds.
I’ve done a fair bit of development in Visual Studio and Eclipse over the years. One of the feature of those IDEs have that XCode strangely lacks is the ability to automatically generate a decent doc comment for a method.
After a bit of googling today I cam across the VVDocumenter plugin for XCode that does exactly what I want. Well worth a look if you want to get into the habit of documenting your code properly. The article linked below provides everything you need to get started with it.
How to Generate Beautiful Apple-Style Documentation in Xcode 5 | Objective C#.
My Macbook has been upgraded through several versions of Mac OS X and the account has migrated over 2 machines. This has led to multiple versions of Python being installed on the system. I never noticed until I tried to use Mercurial and it fell over complaining about the versions of Python things.
Looking in the folder /Library/Python shows that I’ve got 4 different versions installed, 2.3, 2.5, 2.6 and 2.7. Running Python from the command line launches version 2.5. The fix, courtesy of this stack exchange, is to run the following in terminal:-
defaults write com.apple.versioner.python Version 2.6
There’s a bit more information in the linked answer if the above doesn’t help. It did the trick for me though, so happy days!
Let me begin this post by cutting straight to it. Sublime Text is awesome. I’ve had it installed on my computer for ages and cracked it out every now and again to edit some simple text documents, but never really used it in anger. Recently I’ve been working on a project on Linux which is composed of various bits of technology written in different languages. I was spending my days bouncing between a combination of C++, Pro/C, Perl scripts and PL/SQL, hopping backwards and forward between various command line tools and IDEs. It was becoming a bit of drag as having to constantly switch modes all the time was breaking my stride and slowing things down.
You often see apps with links, hashtags and usernames embedded in labels. I’m thinking of the many Twitter and Facebook clients out there in particular. I wanted to achieve the same effect in a client app I’m writing but there didn’t seem to be a nice way to do it with the native UIKit controls. Yes, I know it’s possible to get close to what I need with UITextView, but this isn’t easy to extend with new link types and introduces problems with interaction when its in a table cell. I tried a few open source UILabel replacements that I found and they all seemed a bit buggy or at least wouldn’t work how I expected them to.
I’ve ended up writing my own UILabel replacement, which you can find here on Github. KILabel is an extension of UILabel that adds the ability to automatically hi-light URLs, twitter style @usernames and #hashtags. It also provides a simple way to respond to users tapping on any of these using blocks. To use it just include the source code in your project and set the custom class of any labels in your nibs to KILabel.
KILabel uses ARC and TextKit so it’s iOS 7 only. It overrides UILabel’s text rendering to use a NSLayoutManager, NSTextContainer and NSTextStorage for rendering text. TextKit gives simple access to all sorts of text rendering operations which allow things like this to be implemented. There’s a useful TextKit primer here for those that are interested and my source code is quite heavily commented so it shouldn’t be too difficult to understand what’s going on.
I plan on extending KILabel as I need to, but if anyone else finds it useful and has any feature requests, please pop them in the comments.
Update: It’s been quite a while since I first release KILabel. Over that time I’ve had a few requests for help and new features. There’s now an update that you can read about here that addresses those issues and adds support for Swift and CocoaPods. – 1st May 2015
Ah, the obligatory Hello World! post. Yes, this is the first post I’ve written on this new blog. After a long absence on the blogging and social networking scenes I’ve decided it’s time to start again. Why? Well, I’m on a new adventure into the world of self employment and I need somewhere for shameless self promotion.
This site is where I will sharing my thoughts on software development and the technology industry in general. I will also showcase some of my personal projects from time to time and include articles and tutorials on things that I’m doing. I’m hoping to post something at least once a week, so check back another time and there should be more here. In the meantime, follow me on Twitter, Google+ and all the other usual places for more immediate, but no doubt less meaningful updates.