Bears, Beards and Bacon - Scottish Game Jam

Sorry, I will not be talking about bacon, but now I have your attention!

Game jams are something I always wanted to do, but made silly excuses not to, such as too much work. And that’s while at uni - I’m sure the amount of free time is not going to be increasing from now on. So, last Friday, on my way out of uni, I spontaneously joined the Scottish Game Jam 2013!

Even though it was sold out, I managed to get an unclaimed sacred Red Band of Jammer, and two glorious artists – @too_artsy and @Wallmasterr – in need of a coder appeared from thin air! Later on @jonbro also joined, and the team Beards of Awesome was born!

One thing I’d say for certain is that if, for any reason, one realises she has a lack of motivation or a bad case of ennui, game jam is the best cure possible. What’s not to like? Spontaneous creativity, fast decision-making and short time space with a clear goal result in simply crazy amount of stuff that (hopefully) gets done with a (hopefully) awesome prototype at the end. No money incentive, no genre taboos, no marketing predictability - just pure materialisation of ideas that were bashed and remixed together just twenty minutes ago!

For me one of the best parts of the jam was the brainstorming. Now, it usually is quite a mixed experience, differing from team to team; however I luckily had a great one with Jonathan Brodsky - some people can think outside the box, but some also ask why the box is on its side, made of cardboard and why do people keep on climbing inside it. Jon is one of those people. I mean, just look at the whiteboard!

Interestingly, even though I’d say I went against all the rules and had a good amount of sleep throughout the jam (averaging 6), the whole experience, retrospectively, kind of concatenated into one prolonged weekend. For me, it was a bit like watching a film – where you get completely lost in the movie magic for a couple of hours – except for the whole weekend.

The theme of the jam was a rather unexpected sound clip of a heartbeat – it has quite strong connocations and is not really as open as themes normally go. However, it made the majority of the jammers try to be more original, because “everyone else will have a ♥ + beat game”. We were using Unity, which is perfect for rapid prototyping, and it showed. Although a couple of times I had to learn whole new parts of the system which I never tried before to get the game ready (hello, Mecanim). Also, Jon had to leave to port Proteus right in the middle of the jam, so it spiced up the development as well!

In the end, we made a rather crazy bees vs bears two-player survival arena, with some cool life-movement-weapon mechanic: the hive that you’re playing as can only propel itself by shooting out bees, which are limited (but replenish) and are also used to stun the bears. It’s quite fun and competitive, and I think might have a potential for something more.

In the end, we managed to grab Dundee Game Jam’s Best Art award and somehow honourably mentioned for Best Code and Best Game Overall!

You can play the one-player version of Go Away Mr. Bear, These Items Do Not Belong To You in the browser, or get it from the official Global Games Jam 2013 website.

Also, check out all the hacky source code on GitHub!

Honours Project - Proposal Presentation

Just recently I finished one of the first steps for the project - the presentation. I gave a talk, really just giving a very high level overview of what I’ll attempt to do and what will (hopefully) come out.

It was a really short talk (under 10 minutes), so it’s really a very quick teaser. Can’t wait to start working properly on the project!


Fun With Catmull-Rom Splines Using GNUplot and Ruby

So recently we were studying all kinds of curves: starting with Bézier, then looking at Catmull-Rom and B-splines. One of the assignments we had was to actually plot Catmull-Rom spline, given a few control points. Now, the problem is quite simple, but I spent too much time thinking of what to learn in order to plot it. R? It’s a bit ugly. Matlab? Can’t afford a copy for home. Julia looked very nice, but I wasn’t really in the mood for yet another language, especially with a bit of a shift if programming paradigm (very procedural). Python also looked great (oh, NumPy), but I’ve already heavily invested in Ruby; although I’ll probably end up needing Python at some later time.

And then I realised - why not just use what I know and love? Unfortunately, there isn’t much going on in scientific/technical scene in Ruby — SciRuby is really the only project that pops up in search.

So, really, I decided to go somewhat low-level and just compute everything by hand, numerically, and plot everything using the very sturdy GNUplot.

A bit of theory

The are a few reasons why Catmull-Rom splines are nice: they interpolate all the points, so the curve actually passes through them (as opposed to Bézier spline). Also they are quite easy to compute and preserve the tangents over multiple segments.

So, what exactly does it look like? Well, the parametric equation for a Catmull-Rom spline, , is

Since it’s most usually used as a cubic interpolation, it takes in 4 points, meaning that any complex curve will have to be split into segments (we’ll cover that later). Also, one of the peculiarities of CR spline is that it doesn’t interpolate the first and the last points (see the figure at the beginning).

Now, the cool thing is that to get the coefficients for the parametric equation, we just use a simple matrix multiplication over all the segments,

Sharply Drawn Lines

Just recently while writing a game in XNA I really needed a simple way to draw lines for debugging. However, after some searching nothing really looked nice and usable straight away. And now, studying various curves in maths, I was thinking whether it would be cool to be able to draw the curves in C# using XNA.

So, after ending up using cpt spleen’s LineBatch code heavily and modifying it to work on XNA 4.0, I decided to just publish the code I used.

Grag the source for the LineBatch class from GitHub.

And here’s a pretty trivial example of it in use. I tried keeping the code minimal, yet still working for this example:

Yields quite a nice looking sine curve (sorry about no anti-aliasing):

Having the power of XNA is pretty cool, since it’s really easy to actually animate these graphs. And remember that the line is drawn not through single points, but through two-point segments (see the main for loop).

Quick and Dirty Sprite Glueing

During the development of one of my small games for a coursework, Guilds and Dragons, I was really trying to create that nice isometric, slightly pixelated feel of old-school RPGs (Baldur’s Gate, Planescape: Torment, Arcanum etc.). The fact that I was developing for PlayStation 2 on Linux kit meant that the game was going to be in glorious 640x512 resolution. The only problem was — I had absolutely no time to draw anything and I am not really an artist.

Thankfully, it was possible to find enough absolutely awesome sprites, thanks to places like Spriter’s Resource and others. However, the best source of sprites that fitted my game perfectly was Reiner’s tilesets. Absolutely great selection of monsters, characters, awesome 8-directional animation and other things. One problem, though, — everything was created in Blender and then output (via scripts) in a very specific way — one file per direction per frame. Meaning this

when we really wanted this

to produce this animation

Now, of course, for games we really want a nice, simple spritesheet. And we want it for all the characters, in all orientations doing all the possible actions (in my case it was around 2200 separate image files). This kind of makes it completely impossible to do it manually (as I tried in the beginning, but it got tedious very quickly).

So, mixing a bit of desperation, Ruby and the black wizardry of ImageMagick’s gem (installation of ImageMagick is left as an exercise for the reader, although I seem to remember Homebrew’s formula was working perfectly last time I tried it), the the following simple script was born.

Now, this is the version I used several years ago when I needed it and only now am releasing it — this means that it is given “as-is”, and is not particularly friendly just now (I was quite new to Ruby back then). If someone becomes interested in this, I’ll update it to be a bit nicer.

Game Wallpapers - Kairo

Recently I got a demo of Kairo — a rather minimalistic puzzle adventure. Haven’t spent much time in it just yet, but one thing that was very striking was the visual style — minimalistic, bordering on spartan, yet with every single “room”/”world” having very cohesive style.

This has naturally led to a few screenshots that I thought might be good enough as wallpapers. So, from now on, there might be a few of these posts popping up every now and then with wallpapers from some of the new games. I’ll try and keep the non-adjusted, as-is look from the game, starting with these (click on the images to get the full resolution):

Pushing a UIViewController From a Modal View

The problem

While working on an iOS project last summer, I stumbled upon a very strange problem. Something that should have been very trivial in iOS views management, yet wasn’t. The problem was this:

How to push a UIViewController from within a modal view.

Or, as someone else asking about it put it:

I want to display a view with push transition inside a view which was displayed with modal transition.

The solution

While googling around, I stumbled upon a great post basically solving the problem. However, I thought it would be nice to package the solution in a simple category for everyone to use. So here it is:

After these files are included in the relevant UINavigationController subclass, the modal controller should be created this way from within the root controller:

UINavigationController * modalNC = [[UINavigationController alloc] initWithRootViewController:rootVC];

// Very important to set the delegate here (see )
modalNC.delegate = self;

... blah blah blah ...

The most important thing here is to set the delegate to self (it is the controller that will still be visible under the modal view).

Then, when it is time to push, just call

[self pushViewControllerFromModal:newVC animated:YES];

from within the modal navigation controller.

Honours Project - the Idea

Due to the very high frequency of updates to this blog, I thought it would be cool to include updates on my Honours Project. This way, there will always be something worth writing about and, hopefully, showing.

So, from now on, just select the honours tag to see all the relevant posts.

What’s the idea

I’ve always been fascinated by procedural generation of game-centred content, and especially landscapes. I mean, Minecraft, of course, brought it to the mainstream along with voxel worlds, but the sheer idea that a whole city can be generated from start (layout, districts) to finish (geometry and buildings) is truly inspiring for me.

I’ve noticed that people have been mostly centred on the kind of modern, high-rise “glass and concrete” cities, which seem a bit generic at times. So, living in Scotland I grew to truly appreciate the nice, old, brick architecture - Edinburgh being my main inspiration. This has always been in the back of my mind, creating a generator of small Edinburghs - given the landscape, creating the whole old centre from ground up, developing ways to describe the architecture on the way.


My first big “wow” moment came, of course, after watching for the first time the demo of the very realistic and nice-looking Introversion’s Procedural City Generator:

There is something really cool about being able to see the algorithms work step-by-step, as opposed to them simply hanging and then giving the final result.

Another interesting bit of technology that’s been developed in this field is Greyscalegorilla’s City Kit. It’s a Cinema 4D plugin that lets you quickly create a city (one of those “glass and concrete” varieties) within the 3D editor. Now, the coolest thing about it for me is its ability to generate cities on non-realistic terrains. Let me illustrate:

Now that’s just amazing - procedurally-generated Inception - something that not many other generators really allow, so that might be one of the things that I really want to implement, given I have the time.

Open Current Directory in Finder

I often found myself getting frustrated of the same problem – sometime, when in Terminal, I wanted to open the current directory I was in in Finder. I’m sure this sounds familiar.

Now, since I moved onto iTerm 2, there is an extremely handy shortcut for precisely that action: + Left click on the current folder name in your prompt. Works great, but what if you don’t have iTerm?

Well, that’s where the great xargs come in!

pwd | xargs open

This simple command pipes the current directory path to the open.

But can we do even better? Yes, actually.

open .

Now we can just alias this in .bashrc to something short and voilà!

alias 'lsf'='open .'

(lsf for ls in Finder)

Beautiful Documents With Markdown, LaTeX and Little Printers

Update: After finishing writing this post, I realised I more or less re-impelemnted gimli. Well, let this be an exercise.

This morning I received a delightfully unexpected update from Little Printer – it’s avaialbe for pre-order! Well, £199 is a bit too much for me just now, but it got me thinking.

I was always fascinated by the beatiful documents LaTeX is capable of producing, but there was always too many gotchas to fully use it in a day-to-day basis (I mean, I did, but it was always nagging me that I could’ve found more things to tweak for further perfection). So I thought if it could be generated from something simpler – like, Markdown. And, of course, it’s a well known problem and it has many solutions.

In the end, I ended up using Kramdown, with quite a few outcomes – for example my university’s maths lecture notes. However, it is still a pain to actually write big documents in Markdown – it always ends up being a Frankenstein of the two.

So I was using this approach for quite a while, yet it was very hacky and just generally being a simple tool that I didn’t have time to improve.

But the release of Little Printer instantly sparked a question – is it possible to get some great LaTeX typography on that device. What could be possible? So, in a way, it acted as a very effective catalyst, pushing me to finally release what I’ve been using.


So, today I’m releasing the very basic form of kramtex – an opinionated wrapper around kramdown with the aim to simplify the creation of LaTeX documents through custom templates.

At the moment, only three templates are provided:


This is a straightforward article class with bare minimum in terms of headers, lists – everything is straight KOMA-Script.

Try it yourself using ./kramtex -t article

Little Printer

This is a version of the article template, heavily optimised for the form factor of the Little Printer. It respects the non-printable area of the roll (perhaps not as perfectly as it should yet). Lists have been compressed as to take the least amount of space and still look great. Section headers have been stylised according to the published publication design principles. I also spent a while getting the microtype to do its magick, so now it looks quite stunning.

This can really be useful for small passages of text you we going to look over (if you want to write corrections on top of text, replace microtype’s final option with draft for extra spacing).

Try it yourself using ./kramtex -t lp

Little Printer To-Do list

Just as a variation on the theme of what can be done, I quickly added a to-do template – however, I’m sure there’s going to be a lot of them around when the printer is released.

Try it yourself using ./kramtex -t lp-todo

Little Printer code snippets?

This one is still an idea, as I ran out of time today. I do think one of the uses of the printer might be in printing small snippets of code, perhaps small algorithms or just things to annotate.

Implementing a template for that should be pretty straightforward as well – just customising the listings package to not eat a lot of space and handle wrapping gracefully.

Anything else?

It should be mentioned that LaTeX is all good and stuff, but Little Printer doesn’t actually accept PDFs. Now, I was thinking of trying to serve them through pdf.js, but instead I went with the simpler option of just using ImageMagick’s convert to output the document in PNG. So, to use that, just append -png option while converting and it’ll also give you that. Since the resolution hasn’t been announced yet, it’s set to 96 DPI.

I must say this is very much work in progress – the code is still very messy, unoptimised and just bad. This is mostly due to the fact this is the first useful thing I wrote in Ruby, so am still learning. A gem might be coming out soon.

Get the source from GitHub.