Revisiting old code

spaceWars

So, before I got a job last year I was working on a little OpenGL project to try and learn how to use modern OpenGL. My goal was/is to recreate, in modern OpenGL, all the assignments I did at uni in “old” OpenGL. The first assignment I ever did was to create a little spaceship fighting game. You can read about my work up until March here.

Coming back to this code after a year of programming professionally -hoo boy. After opening it the first time I thought I’d forgotten all the OpenGL I’d taught myself last year. And while rereading it all to get reacquainted with my old knowledge I frequently cringed at my bulky and clumsy classes.

Despite the flaws I thought I should finish this project off and tidy it up a bit before moving on to something else.

So in the last week I’ve added health to both the player and the enemies and, consequently, “power” to the bullets. The enemies now get smaller as they are shot (mostly because I wanted to make sure I could scale stuff properly) and the player will get progressively more red as their health moves towards zero.

Now when the player dies the game will return to the start screen so you can play again. I should really add this ability for the scenario where the player defeats all of the enemies too. I’d also like to add a “winner” and “loser” screens to make this feel a bit more like a game. Maybe also a timer or score so that players can record their best scores – this would give me practice with saving.

After messing around with health and “power” though, it has become super clear that my old classes are really quite awful. I don’t want to rewrite the whole thing, but a small refactor to create a “spaceship” class would be a good idea. Maybe after some thought I could clean up the Gamescreen class too.

Feel free to check out my code – though the latest updates have really all been gameplay rather than engine or graphics code.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s