Linux game development

I really love developing on linux. I also love video games. So why not combined the two?

A little while ago, Valve announced that they are going to be supporting game development on linux in a meaningful way. I thought, “this is awesome!” But then, I looked at the state of gaming on linux and I was a bit confused and then a little disappointed. You see, there are more games coming to linux but it seems a lot of them are Windows games that are played through emulators or virtual machines. I think it is great that we have that technology, but where are the ‘linux’ games?

I don’t mean games should be made so that they can only be played on linux, but with so much development done on linux where are the developers making games on linux? Where are they hiding?

The short answer is “I don’t know.”

I hope to revisit this post with some kind of “there they are! It was right under my nose!” post. But for the last few days I have been looking for a game development forum for linux developers and really found nothing. I spend a good deal of time lurking on (a great website and remarkably good source of software knowledge too), but even there it is really hard to find people working on linux.

And then there is the prejudice.

It’s not that I am unaware that developers on different platforms are partisan, but I was surprised by the depth of ignorance about where linux is as a viable consumer platform. Don’t get me wrong, linux is still a more hands-on platform than either Windows or OSX, but it has definitely moved beyond the device-driver hell that many experienced in earlier days.

You know, I really don’t want to dwell on that side of things. I don’t want to fan the flames of partisanship. If you are a Windows developer — awesome! I am glad you are doing something that you enjoy. If you are interested in Linux, I would love to share my enjoyment of it with you.

And at this point I wonder if I have to be the one to make this happen? I am not a natural leader but I want this to happen. I want to make and enjoy games on linux.

Why I love linux (and gentoo in particular)

So currently I have a gentoo VM on one of my windows machines at home. My preferred environment for developing on linux is using the awesome window manager with vim and urxvt. But on this particular installation there was something messed up that was preventing my from using control+shift+6 to switch between buffers in vim. The problem was that urxvt was capturing the control+shift key press as a hotkey combination for something called ‘keycap picture insert mode’. Not sure what that is, but I am sure I can live without it.

I ask my friend google, ‘who has encountered this and what I can do about it?’ No one seemed to know of a way to easily disable the hotkey feature in urxvt and the only option seemed to be that urxvt needed to be compiled without ‘iso14755’. This is where being on linux is nice; At least you have the option of recompiling and shaping the software how you want to use it. Unfortunately, the ease with which that can be done varies with packages. But, I’m using gentoo and this is supposed to be its party piece.

So I look into the documentation on portage and USE flags, which is fantastic BTW, and it looks like it should be as easy as adding a line to /etc/portage/package.use telling emerge to not use iso14755. So I add a new line to package.use and then emerge rxvt-unicode

And now urxvt just works as a I want it to.


sed -i

I’ve used sed for a long time, and maybe at one time I was aware of the -i option, but it has long since been forgotten until recently. The -i option is allows you to apply a substitution ‘inplace’, i.e. to overwrite text in the file you are processing. This is really something that should have been in my linux toolbox before now. Hopefully, this time I won’t forget it.

Handy ps flag

Just came across a flag that I have not used before with ‘ps’. It is the ‘f’ or –forest flag. It formats the output from ps so that you can see the child-parent relationships between processes. This was especially useful for me because I have this problem where an ssh connection in a urxvt terminal becomes unresponsive — I can move and resize the terminal but I cannot for the life of me break out of whatever state the connection has gotten itself into. The only solution I have found is to kill the terminal. Unfortunately, I always have other terminals running so a simple ‘ps uax’ only reveals a set of pids relating to the urxvt sessions. Now, using the magic –forest flag, I can see which of the terminals has created the ssh connection that is causing me trouble, and I know exactly which process to kill!

Being a teacher means being a leader

I have a long-standing interest in leadership. I find it really interesting that some people are particularly effective at motivating and directing people, whereas others are not. I have also wanted to write an article about leadership for a while, but I have never been sure where to start or what to cover. I am certainly no expert on leadership, more of an interested observer. Nonetheless, I saw something today that affected me today and I feel the need to get some thoughts out of my head.

I like to play soccer, and although I don’t play competitively any more, I like to go out on the weekends and kick a ball around. It is early fall and it was wet and noticeably colder than last month. There was a childrens team practicing on the other side of the field and it was hard to not hear what the coaches were saying. There were three adults (parents I guess) and one of them was The Talker. Unfortunately, he wasn’t terribly effective at getting the children to do what he wanted. The expression, ‘herding cats’ seems appropriate, but then that’s children for you. So he became frustrated and ended up shouting at the kids, berating them, and putting them down. It’s not an easy job teaching children, but this was an avoidable situation.

I recently finished reading the book ‘flow’ which is essentially about creating a happy existence by trying to be engaged in whatever activity you are performing. So this is something that I have been thinking about recently and couldn’t help applying it to the situation I was witnessing with the children playing soccer. One situation in particular stood out: they were practicing crosses from the corner where the Talker adult would kick the ball from the edge of the field to the children who were in front of the goal — the attackers trying to get a goal and the defenders trying to stop them. Now, these were children. Maybe 8 — 10 years of age. When an adult kicks a soccer ball at you from about 30 — 40 feet away it can be a bit intimidating to try to stop it. Clearly these children were not excited about the prospect, and it didn’t help that Talker adult wasn’t particular accurate. The result was that Talker adult became frustrated as the ball usually flew over the children or the children leaped out of the way of the ball. So he ended up shouting and berating them, and they mostly stood around doing nothing in the cold and wet just getting bored. Any wonder that they started acting up?

Practicing crosses in the goal area is a great thing when the players are not afraid of the ball and know how to head the ball at the goal. But these children were not at that point. The coaches should have started with something more basic. First, the children need to be doing something so they are not getting cold and bored. Second they need to feel that they are working at something that is challenging, but not too difficult or intimidating. Perhaps the coaches could have had the children line up in front of the goal and simply thrown the ball in the air for each child to head. This makes it less intimidating for the children and they get to run around. Once they start to understand the routine maybe add to it by having child that last headed the ball be the person to throw the ball in the air next to build on the teamwork. But the idea is to present a challenge that you know they are capable of, and when they become confident increase the difficulty a little to make sure they are doing something achievable but challenging.

Being a teacher means being a leader. The goal is to motivate and teach by engaging the interest and building the confidence of the student through realistic challenges that allow the student to succeed through work and effort.



A place to stash ideas

One of the tools that I have wanted for a while is a place where I can dump information that I come across on the web. Often I don’t want to read an article immediately but I don’t want to forget it. Or, I read it but don’t want to lose the reference. Now, I am sure there are plenty of apps specifically tailored for this, however, for this kind of information I find it particularly handy to use google+.

Previously I have burdened my friends with links to articles under the pretense that they may be interested. However, there are some things that are pretty random and make little sense to share, and I don’t want to become a source of noise that irritates people. So I have created a special circle called ‘stash’. I have added no-one to the circle and I just dump stuff in there that I want to remember. E.g. I am currently trying to learn modern opengl and there are a bunch of online resources out there that I am working through. So I just added these to my stash and if I want to annotate the URLs I can added comments.

Why not just use bookmarks? There are several reasons. The first reason is that I just don’t use bookmarks because I don’t really like them. Over the years I have just found they don’t fit with the way that I like to work and, for me, they are just not an effective way of curating information. Also, as mentioned above, I can add annotations to the URLs via comments, which I think is a really useful. Finally, (and this is something taken from the ‘getting things done’ method), it is really nice to have all of the information contained in a single system that I can use anywhere.

Line-ending replacement in VIM

I have often had trouble using regex in vim when it involved line-endings. So I found today that there is something of an asymmetry to the way that you search for line-endings versus replacing line-endings.

To search for line-endings you use \n but to replace or insert a line-ending you use \r (on linux). So if you wanted to replace duplicate empty lines you use,


JSON and the namedtuples

I have been working on a web application using tornado, which is a python framework. I love it. I have been having so much fun playing around with it, and working in python is a joy.

When there is a request that contains a JSON body I naturally convert the body using the ‘json’ module. But this is not quite what I want. I like dictionaries, but not when I really want to refer to fields on an object. I could create a class to convert from a JSON dictionary-based structure to an object, but I’m lazy and don’t want to do that. So I looked around the internet, convinced that there had to be an easier way of doing this and there was! Of course, the ‘json’ module is all set up to handle this and (combined with the magic of namedtuples) translating JSON into an object is trivial,

import json
import collections
Session = collections.namedtuple('Session',['state','id'])
session = json.loads('{"state":"confused", "id":"foo"}',object_hook=lambda args: Session(**args))

SSH keys and agents

Recently I was playing around with EC2 and wanted to rsync a whole bunch of data on an instance. Because Amazon uses ssh-keys to provide secure logins you provide the identity file when you login. This is simple when simply logging onto the server to noodle around, but how to provide the key when trying to rsync via SSH? The answer turns out to be pretty easy,

eval $(ssh-agent)
ssh-add ~/.ssh/[my-public-key]

This starts up an agent and passes your identity file (SSH key) to the agent, which forwards the file (during the current session) whenever using SSH. So once you have perform this small invocation, you can simply use rsync to copy to the target server,

rsync -avz [some-place-on-your-machine] [user]@[server]:[some-place-on-server]

Getting rid of multibyte characters

Today I was converting documentation from a google doc to markdown that could be converted to HTML using pandoc. Mostly this is pretty easy because you can just save the document as text and you’re done. However, google does like to put nasty little multibyte characters into the document for some reason and pandoc does not like this. Fortunately, there is a simple remedy for this problem using sed,

sed 's/[\x80-\xFF]//g'

Just apply this sed script to the file and it will remove the multibyte characters.