To refresh my Java skills I started making a little game. I’ve always liked the good old Thrust and back in 1994 I wrote a similar game for the Amiga. Back then it took me 3 weeks of hardcore assembler coding. The Amiga had hardware support for two layers of graphics and 8 sprites(Smaller graphics objects). This included hardware collision detection between all those elements. This made it fairly easy to write a game with a ship (one layer) and stuff that it shouldn’t hit (The second layer consisting of a tile based world.) and a bunch of missiles(Sprites) that the player could shoot with.
The result was a nice little game where the player controls the rotating spaceship through a maze of rocks, shooting stuff, and carefully maneuvering towards the exit. It had multiple levels, sound, and high score table.
Now 15 years later I wanted to recreate the game on the PC… of course bigger and better.
“With the fast computers we got nowadays I can make the same in Java without bothering much about optimization”, I thought and quickly coded a tile based rendering system.
The first results were truly disappointing. My 3GHz Quad Core PC with an Nvidia 8800 that usually runs Team Fortress with 150FPS could run my crappy prototype at 20FPS. Something had to be wrong.
I spent several hours looking at how Java draws images on to the screen, and found out that even though its really easy and straight forward to draw BufferedImages to the screen, there is a bunch of advanced stuff that you can do to prepare the images for quick rendering. After rewriting the renderer so that it first reserves a proper output area(Supported by hardware), and preparing the images so they fit this hardware accelerated area, the game ran with more than a hundred frames per second. This is fine for now, but I’ll probably look more into it later.