xonix mobile edition

Having toyed around with J2ME for the freeVibes, I got a bit hooked on coding for the mobile phone.

So I started to recreate the classic oldskool game Xonix, it’s a game I really like. So simple and addictive. It’s not the first time I’m coding it, I have made it as an applet about a year ago (Xonix applet). As well as being a fun game to play I find it a fun game to code too. Though I have had my share of frustrations. The basic functionality is a fillalgorithm, that has to fill an area on both sides of the line / trail you make with the ‘pilot’. This has to be fast and efficient – nobody likes a game where you have to wait for updates.

xonix screenshot

When I first made the game i found a neat fill-algorithm. (flood fill wikipedia). So it should have been a piece of cake to implement it in J2me, its java… I deliberately choose not to reuse old code, as I feared it would be horrible ugly. And a course in datastructures and algorithms should have given me some tools to make a better / cleaner implementation. Then the woes began. J2ME, has no ArrayList it has vector and a stack, and the are not generic so no typecasting. I made a version using Vector, but somehow i managed to use all the memory. When I look back I have a nagging suspicion that the Vector isn’t to blame – but rather me that somehow feed it to much data. No matter what it was I got rid of the Vector and started using arrays, and using indexing like in images or c-“double”arrays (index = x + y * WIDTH). Finally it could fit in memory.

And then I started looking for graphics, a nice game really depends on nice sprites – much more than a beautiful algorithm. I couldn’treally find any and its quite painful, at least for me, to make sprites. It gets real ugly, real fast – hmm no it gets real ugly real slow, because i’m no good at creating graphics. Well the frustrations grew and I ending up abandoning the project. The basic gameplay works, but is buggy and as mentioned the graphics sucks.

xonix screenshot 2

All in all it was quite fun programming, and some day i might give it another go.

Leave a Reply