Barak Cohen's (1+ε) Cents: Computer Science and Algorithms Blog: October 2009

Wednesday, October 21, 2009

QBert 3D: Java with OpenGL Open Source Impelmentation

Q*bert was one of the more popular arcade games back in the early 80's. It features Qbert - a cute little fellow with a large snout that jumps around pyramids of different sizes while being chased by evil enemies seeking to annihilate him. Just to top things off, there are also large scary balls falling down the pyramid posing yet another threat to poor Qbert. To successfully complete a level, Qbert must jump on all the cubes comprising the pyramid.

Today I have for you another project from the Computer Graphics class I took last year. This time, a 3D version of Qbert, implemented in Java and OpenGL (using JOGL). As always, a large part of the credit is due to my partner in crime, Gur Dotan. Click here to download.

To run the game, unzip the download, open a command prompt, change to the QBert3D sub directory and then type "java -jar Qbert3d.jar".

Use the arrow keys to control Qbert's movement. It's a bit tricky at first because the turns are always with respect to Qbert's current direction. For example, if Qbert is facing you and you hit "right", Qbert will turn right, which is your left. Try to put yourself in Qbert's position and play as if you're Qbert. You can also hold down the left mouse button and move the mouse to rotate the camera so you can see where you have cubes not yet visited. Release the button to return to the normal viewing settings.

Each level has a corresponding XML file in the Levels directory. Inside each XML file you can edit the number of balls, enemies, their speed and intelligence but the real nifty part is the matrix in the end of the file where each entry specifies the height of the board at that point. This feature allows you to create non-pyramid levels! Feel free to create your own levels and if you send them to me, I promise to post them here.

There is also a Word document that describes some of the basic principles behind the design and coding of the game. The source code is also included and should be fairly easy to understand. As always, you are welcome to modify, redistribute, refactor, debug or anything else you want. I only ask that you give credit where it's due (to me and Gur) and let me know so I can check it out.

Download Qbert 3D