Wednesday, 28 January 2015

Class Wars

After a few days, Simple Game is well underway. I've been tackling some programming challenges and met with some working results.

First off was writing some collision detection to keep a marble inside a given path. This was more tricky than I first thought, with the marble getting stuck and so on - usual collision detection type bugs. It's working in a basic fashion now - following the correct path, not getting stuck etc.

Today, I spent a while on some particle effects. Specifically, creating an explosion effect by dicing up a sprite into a load of pieces. Previously I'd only ever used little square or lines to create the effect of something exploding. As my sprites are mostly simple squares at the moment, you don't get the best result but it does work as intended. Functionality needs expanding to be more flexible and allow for multiple explosions.

Code-wise, I'm still somewhat baffled by how exactly to use classes "on the fly". Right now, I've created everything at the started and am managing classes with "alive" booleans and so on. Maybe that's the best way to do it, maybe not. It certainly works OK.

I don't yet have a sense of how Java's garbage collection works and when exactly my classes are destroyed. I'm not sure if I'm creating classes over and over, taking up more and more memory. This will need to be looked at sooner rather than later else I'll go a long way down the wrong road, writing sketchy code.

This evening, Simple Game is playable, in a sense. You can't really win or lose yet but you have some control over what happens and the game's rudimentary automation seems to work smoothly.