Birdshooter simple 2D Java game

projectC1

This is a project I made while learning Java programming in school. The first “real” game I made in Java, complete with animation, a graphical user interface, sound effects, and irritating background MIDI music.

After I had learned a little about user interfaces in my Mastermind-games, and about object-oriented programing in my database program, I wanted to make a larger object-oriented project that involved both animations and user interfaces. And what is a better idea than making a new game?

This project also introduced a few new things such as: How to use double buffering to make smooth animations, and how to integrate images (.png) into the graphics. I also learned how to write code to play sounds. This game has a few different sound effects in wav format, and two different MIDI soundtracks are used as background music.

In this project, I use inheritance between classes to make the code more efficient. For example, I have one class representing a cannonball (named “Ball”). This class describes the general properties of a cannonball, such as weight, speed and direction, and other attributes. This class also contains the math used to calculate how the ball moves through the air, and functions for accessing the position and image of the ball.

Then I have a class “KilledBird” that is representing a bird that has been hit by a cannonball, this class is a superclass to the class “Ball” described above. This means that “KilledBird” inherit properties from “Ball”, for example how the ball flies through the air. This makes the code more efficient and I do not have to write the same code two times.

projectCabout

Download source code

Click here to download the source code.

I have used a free Java IDE called “jGRASP” to develop this program. The zip folder contains the source files, and all image and sound files used by the game. You need to compile it before you can run it.

One thought on “Birdshooter simple 2D Java game

  1. David Lee

    Thanks for the wonderful game with source code. However, when I run the program, I get “a lot of” errors. I’ll just copy and paste the whole errors (it’s really long).

    *removed all the error messages

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Warning: Undefined array key "rerror" in /customers/b/a/5/brinkeby.se/httpd.www/axelsdiy/wp-content/plugins/wp-recaptcha/recaptcha.php on line 291
 

This site uses Akismet to reduce spam. Learn how your comment data is processed.