GameGrid: Game programming with Java

Research project PHBern  
HomePrintJava-Online

Exercise 7: Alien Game

20 aliens actors are generated at random locations in the upper part of the grid and move downward. The dart can be moved by mouse. When you hit an alien with the dart, it is destroyed.

The goal is to destroy all the aliens with the dart, before they reach the bottom. If an alien reaches the bottom, you can not destroy it anymore. It changes the color to green and starts moving back and forth.

As template you can use the file AlienGame_0.java

Edit AlienGame_0.java in the Online-Editor

Download: AliensGame_0.zip

 

It is recommended to develop the game in the following steps:

Step 1: Create 20 aliens at random locations in the grid. Extend the act() method in the class Alien so that the aliens move downwards.

Step 2: Edit the act() method in the class Alien. If an alien reaches the bottom

Step 3: Count the remaining (red) aliens. The number of aliens can be displayed in the title bar. If the player managed to destroy all aliens in time, "You win" is shown in the title bar.

Step 4: Find own ideas to make the game more interesting. Take also a look at Space-Invader.