Mr Monocle – The Post mortem
I’m “done”
“Done” as in, some stuff left to do, but I give up. The game is playable and submitted. People can play it. I will release a Windows version tomorrow-ish. (The XP laptop is asleep and I don’t want to wake it up and start downloading files)
So… I went to sleep on a friday after a long evening of Call of Cthulhu RPG playing with my wife and brother in law. Got to bed about 3am. Up again a few hours later and started to code on my entry around 7am, 2 hours after start. (local time, but you all knew that)
After some quick thinking with a tired brain, I decided my entry shold contain a monocle wearing gentleman on a penny-farthing. The penny-farthing should fly and the player should press and hold space to make it fly higher, and release the button to fly lower. Kind of like all those flash games nobody plays.
But when the first version of the map code was up and running I decided that he should ride the penny-farthing on the ground instead, so the game was transformed to some sort of top-down racing game. And the rest is pretty much history. I didn’t really have a big todo list from the start. I had a few ideas and everything else was thought up, and included, on the fly.
It was an interesting experience for me. I have never done a game in Ruby before. And I have never used Gosu, the game programming library that powers my entry. It turned out pretty well, I think. I really like Ruby because it makes most things pretty easy to do. Gosu was also very easy to use, and I will continue to use it in the future.
What Went Right:
The game runs smooth, even on this macbook with a intel graphics card. I knew before that Ruby isn’t the fastest language around, and I have heard bad stuff about its garbage collection, and how it can make games stutter and lag. I’m not sure I noticed it. At times things was behaving a bit bad, but I had a timelapse movie in the making at the same time and I believe it caused most of the poor performance. I also had a bucket full of apps open at the same time, so I’m not ready to blame Ruby and its GC just yet.
Not sure what else to write. It got done. That is something that went right.
What Went Wrong:
Well, where do I start? Entities and their controllers? I used a new approach for me when it comes to game programming. I followed a short tutorial on how to use Gosu and Ruby. And it used a Model View Controller layout for the game. “Fine”, I though. I already use that when I code in Ruby on Rails, so I’m not a stranger to that. But I made a poor implemention of it. An entity in my game has a model. The model describes what it is and what stats it has. (position on screen, image to show, velocity, etc). Every model needs a controller. The controller tells the model what to do. But I keep these in separate lists. Luckily, no bugs turned up making this fall appart. But instead of having two lists I should have only had one with models in it. And each model should be responsible to know where its controller is. Instead of updating the controllers I should update the models, which in turn updates their controllers. Or vice versa. Not both. That made a mess out of things.
I’m not happy with the map! For some strange reason I though it would be a good idea to store the map as a long list of strings. Each string could look something like this: “3;9;3″ which means, 3 solid tiles, 9 empty ones, then three solid again. This would save a lot of space and be a nice thing. Making a pillar in the moddle of the column would look like this: “3;4;1;4;3″ (3 solids, 4 empty, 1 solid, 4 empty, 3 solids)
But… WHY? What was I affraid of? Why do I need to save space? It only made things much more complex during rendering and collision detection. And when I realised that, half the compo was over! Too late to change now, just keep going! This of course makes things a bit more complex when it comes to detect what’s to the left and right of a tile. Notice in the game that the stalagmites, or whatever they are called, only shows below and above a column of tiles, and never on the sides? I didn’t even try to write code to allow me to check the sides, thinking it would slow down the game a lot. Next time, don’t diss the good old tilemaps!
Music! I’m not good at making it, and it turns out neither is the computer. The result you hear is at least a lot better than my first attempt! cfxr is a nice tool to make sound effects with (I love 8-bit sounds). However, my attempts of making musical instruments in it failed in an epic way! So maybe it doesn’t sounds good, but be glad I rewrote it and switched to some samples I found online.
Difficulty; have you played the game yet? Enough said!
Collision detection — I’m doing it wrong! It got better during the second day of the compo. It was a rewrite I had to do! It’s far from perfect and I don’t like the code, but it works. Kind off. Please ignore that you sometimes goes through a piece of the wall before you die. Use it to your advantage instead. Sometimes your should be dead, but isn’t.
And finally, how things usually turns out in my code. I have heard that globals are Bad(tm). Avoid them like the plague, they say. And I do. Stuff is passed from and to the classes and stuff. But sometimes class A doesn’t know about B, and it would be silly if it did, but it must, otherwise I can’t do C. So I hack it in. Now A know B and C is done. But then C needs to know about A, so I have to make a short cut here. And then one there. And before I know it, it’s a mess! And today I found out that I had 3 methods that pretty much did the same thing. Did a quick code refactoring, but I felt silly. The rest of the code is ugly too. But it was written in under 48 hours so I shouldn’t complain.
Closing Words:
I had a lot of fun! I will do it again! I have done similar things in the past (game-in-a-day, and my own Im-bored-will-code-game-in-12-hours private compos), and really enjoys it. I hope you like my entry. Thank you for reading my rant.
Link to entry: here