Pages

Saturday, October 20, 2012

The Friday Project - Update 1

Level creation

The Goal

My main focus for the day was to simplify level creation. Last week I'd created a simple demo, with 3 hard-coded levels, just to see if the game was playable. This got things moving quickly, but had the disadvantage that all of the levels used straight lines and right-angles. During the week I had experimented a little with the idea of creating levels with a drawing package, but the learning curve was a little steeper than I had hoped. Finally I remembered an idea I'd used previously, which was to build the level out of track pieces as you might find in a car racing game such as Scalextric. I was even able to take advantage of some code that I'd thrown together on Play My Code. It's a lot easier to demonstrate than to explain, so here it is:



But that isn't the whole story, as the track pieces in that game are all of a fixed width. The whole point of Whirling Frenzy is that the course is varied, so some adjustments were necessary to cater for variable widths, and asymmetric track. Fortunately that didn't take a huge amount of time, and by the end of the morning I'd recreated the 3 levels that I'd made previously and had added a new one which was far more complicated.

Rendering and Culling

Having met that goal, it was time to move away from the libgdx Box2D debug renderer. There isn't that much to tell here, except that libgdx has a simple ShapeRenderer which is, as it happens, used by its debug renderer. This renderer is, as its name suggests, great for simple geometric shapes such as the surface of the track and the track walls. It will certainly suffice as a placeholder until the art direction of the game is decided. To be honest, I quite like the clean, uncluttered look that it gives the game.

The only problem is that it didn't work as well as I had hoped, because as soon as I tried the new complicated level on my ancient and venerable Nexus One, it started to stutter. My PC didn't bat an eyelid, and my new phone, the excellent and awesome Galaxy SIII also didn't bat an eyelid, but that poor old Nexus did not like the amount of work it was being asked to do. No small wonder,  as it was being asked to draw everything in the level, 60 times a second.

That was fixed by relatively simple culling, whereby any object whose rectangle didn't intersect with the viewport was dropped. There are undoubtedly better ways of doing it, but that was good enough to fix the problem. Given that my time is limited, I'm trying to overcome my perfectionism and go for "good enough" every time.

Reflection - Friday is for execution

This is the second Friday that I've been able to take several hours to work on the game, and both times it has paid off. During the week, I decide what my goals are, and when I get time I might play about with a bit of code, or try to learn a new tool such as a drawing package, or I might just make notes about how I'm going to do something. So, when Friday comes around, I know exactly what I'm going to do and I just do it. It's certainly a lot more productive than falling asleep at my keyboard at 10pm after a long day, because it's approximately 7 hours when I'm wide awake, I know what I'm doing and I won't be interrupted. It makes a huge difference.

Playable Snapshot

QR codeI don't really expect anyone to want to do this yet, but if you're keen then you can 
 click on this link to download the latest Whirling Frenzy snapshot to your Android phone. You can also download it directly using the QR code. Don't expect fancy graphics, sounds, scores, or anything other than 4 simple levels and a spinning compass needle, because there's nothing much to see. There are two control methods, tilt controls, and the virtual "anywhere" joystick from Very Angry Robots.

Even at this early stage, any feedback is welcome.

Finally, thanks to @thegreystudios for nagging me to write this blog post.

No comments:

Post a Comment