Missile Command

Missile Command is a very simple game in which the player (you) has to defend the city from the falling meteors by using the three basses to shoot missiles that destroy the Meteors. if you fail and all the buildings are destroyed then you loose.

MC

MC

The Meteors continue to spawn until the player can not hold off the meteors anymore.

Meteor Spawn Code;

 

public void act()
{
shoot();
if(delay % 100 == 0){
spawnMetor();
}
delay++;
if(delay == 200){
delay = 0;
}

}

public void spawnMetor()
{


Random generator = new Random();
Random r = new Random();
Random numGen = new Random();
int randomInt;
randomInt = generator.nextInt(getWorld().getWidth());
getWorld().addObject(new Metor(),randomInt,0);
}

The Meteors spawn every few seconds with a delay.

The missiles shoot from each base and only one spawns per base.

Missile Shoot Code;

 


public void shoot()
{
//MouseInfo mouse = new MouseInfo();
int mouseX = 0;
int mouseY = 0;
int button = 0;
MouseInfo mouse = Greenfoot.getMouseInfo();
if(mouse != null){
button = mouse.getButton();
if(button == 1) {
mouseX = mouse.getX();
mouseY = mouse.getY();
//System.out.println(mouseX);
//System.out.println(mouseY);


getWorld().addObject(new Curser(),mouseX,mouseY);
getWorld().addObject(new Missile(),10,370);
getWorld().addObject(new Missile(),300,370);
getWorld().addObject(new Missile(),590,370);

}

}
Once a Meteor hits a building it changes its “stage” to a more destroyed look until its just rubble on the ground.

Building Pictures:

Building_1_GF_MC
Stage One

Building_2_GF_MC
Stage Two

Building_3_GF_MC
Stage Three

Building_D_GF_MC
Destroyed

 

The Meteor
Metor_GF_MC

The Missile
Missile_GF_MC

(Custom Graphics)

Leave a Reply

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