Joshua Mayer's Rasterizing Bi-Plane Game

Scroll Over Pictures for Description

biplane

biplane

Description

3D Bi-Plane Game

I began my bi-plane game by creating the GUI that would display the game. I decided to use JFrame as my GUI library and set up a 720x720 window with key listeners observeing the arrow keys. I then had to convert my previous rasterizer to output a bufferedimage instead of a bitmap image. This required me to also change the way I set pixels, I used the bufferedImage's setRGB() method that requires a integer value for the color of the pixel. In order to compute this value I converted the red/blue/green values to hue/saturation/value values and then used the bufferedImages HSVtoRGB() method to get the appropriate integer value for the color model of the image. After I got an appropriate output type I had to set up animation to test the game. In order to do this I created two variables, anglex and angley, that are altered by the arrow keys and that ultimately change the angle of the plane. To perform this transformation, I created two matrix multiplication methods. I had to rotate the plane before moving it around the screen, so the matrix multiplications occur as soon as the original values of the plane are set. After rotating the plane I move it around the screen (always moving forward as planes dont really have that much freedom of movement). I then tested my game and saw that I had two main problems. The first was the need for a z-buffer (which was easy enough to implement though I could never overcome z-fighting) and the second was the slow jerky animation. I realized I needed to do major speedups to my game to have it work properly. The first thing I did was to store the values of the bi-plane's mesh in an arraylist instead of a file. Then I tried to get rid of as many floating point operations as possible, and replaced divisions with bitwise shifts. I then replaced the loop that set the background with a fill method of bufferedImage (setRGB(width, height, offsetx, offsety, []colors, scanline)). Now my game worked fast enough for smooth movement and I had to implement and actual game mechanism. I chose to do a gem/mine game in which the amount of mines on the screen is porportional to the amount of gems collected. In order to not overpopulate the screen and make the game impossible, I set the mine limit at 25. For every gem collected the user gets 1 point and for every mine hit the user gets -1 point. The mines and gems are 2d triangles (black and multicolored respectively) and the locations of them are saved in an array. In order to delete a mine/gem that has been hit by the plane, an intersection is looked for and then I delete the screen space value from the array.

My source code can be found here