Just moozing

Before you can check your notes, you must make them…

Unicorns everywhere – a Gamejam writeup

leave a comment »


unicorn hunt screenshot

This blog post is about my first gamejam, that we did some weekends ago.

In short, a gamejam is about creating a game in a very limited amount of time. It was a first for me. I did the mandatory snake game in my teens, but nothing since then.


The setting

The format was that we met up Friday evening, decided on a topic, formed groups, and got started. On Sunday there was presentations and a vote on the best game.

We were around 20 people, and we formed 5-6 groups. Everybody except me wanted to use unity, so I formed my own group to do experimentations with pygame.

It was clear to me from the beginning, that I wanted a graphically simple game, and the a game play was a non-imaginative tiles and sprites-in-tiles. This led me to create the graphics: grass tile, maiden, unicorn and badguy. I used GIMP and drew something in 32×32 pixels – anyone can make something mostly recognizable when it is that small.

And then the pygame programming took over. I have used pygame before to get events from my game pad to control a robot, and I wanted to work with the graphical part.


Programming and designing

It was fairly straight forward with a lot of copy and pasting from pygames documentation. All frameworks has a built-in logic, and a way they are intended to be used, even if they can used differently. I did the classic box thinking, where each object is able to draw itself given an offset – this seems to be non-pygame’ish, and a better solution is for the object to know its location. This would make updating the game area easier.

I did a design with having actions on the units in a dictionary as opposed to having actions as class methods. This enables a lot customization to individual units, but might be a handled better by inheritance.

The action class in itself was a good idea. It enabled the concept of time to be introduced. This way I made the unicorn go faster and the maiden to be slow. Being pushed made the unit unable to move for a set period of time. It would be simple to include sound effect as part of actions.

In the end, I ended up with a game where two local users share the keyboard. I – almost – succeeded in making it a networked game, where users can log in over the network and control one the sprites. It is currently disabled in the code. I tried to do multithreading and sending a pygame event to the main thread. It worked with the first connection, but not with multiple connections – at least I don’t get segmentation faults and program stalls. Multithreading will give rise to odd issues, and I decided to make the game playable instead of spending too much time on debugging.

And on a side note: doing sockets will give you issues related to blocking and non-blocking. Read about here. The questions are how to know you have data available, if the connection is broken, if the sender is done sending, and so on. My current implementation is brittle, and is in need of a do-over, probably either using UDP or a newline delimited text protocol.

Looking through the code two weeks later, I see a lot of potential for refactoring. During the weekend, it also started to be obvious that the code was getting bigger and more complex. My usual rule of thumb is that, I miss unittests when I cross 100 lines of code. The game is 1000 lines, and debugging became very difficult.

I also would like to refactor to follow the guidelines for high maintainability – that helps in debugging also.



From a learning perspective, it is interesting to see the effect of people working in groups with a very specific (self-defined) focus under harsh time restriction. Students are able to work hard, focused, dividing tasks, delegating tasks and all the other thing we really want them to do in school projects. They work a lot and learn a lot. I would like to be able to take that into the classroom when I teach (but have no idea of how to do it)

Personally, taking time out the a busy schedule to do just one thing, should be done more often. You just work more efficiently when you have decided to not do mails, phone calls, family and job related work, and focus on that one specific tasks. It should be a priority to do that from time to time.


Notes for next time

  • do better graphics
  • do sound
  • be in a team
  • include unit tests from the beginning


Written by moozing

October 1, 2016 at 12:00

Posted in Tech

Tagged with , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: