// RocketGun.java
import ch.aplu.jgamegrid.*;
import java.awt.event.KeyEvent;
import java.awt.*;
import java.util.ArrayList;
class RocketGun extends GameGrid{
ArrayList<Actor> rockets1 = new ArrayList();
public int i;
int[]typ1= new int[i];
public RocketGun(){
super(600, 600,1,null,"sprites/galaxy.jpg",false);
.....
}
public void Player1(){
Player rocket = new Player();
.......
}
public void Aliens(){
RocketsTyp1[] rocket1 = new RocketsTyp1[4];
Location loc = new Location(0,0);
while(i<4){
rocket1[i] = new RocketsTyp1();
if(isEmpty(loc)){
addActor(rocket1[i], new Location(loc));
delay(1000);
rocket1[i].show();
i++;}}
}
public static void main(String[] args){
RocketGun galaxy = new RocketGun();
.....
}
//<---Begin class Player--->\\
class Player extends Actor{
int n;
public Player(){
super("sprites/rocket1.gif");}
private void shoot(){
if(gameGrid.getNumberOfActors(RocketsTyp1.class)!=0){
..........
rockets1=getActors();
n=rockets1.hashCode();
switch(gun){
.........
} }
}
public void act(){
..........
}
public int collide(Actor actor1, Actor actor2){
Location loc= actor2.getLocation();
Actor rocket1=gameGrid.getOneActorAt(loc,RocketsTyp1.class);
actor1.removeSelf();
typ1[n]--;
if(typ1[n]==0){
rockets1.remove(actor2);
actor2.removeSelf();}
...........
}
}
//<---End class Player--->\\
//<---Begin class RocketsTyp1--->\\
class RocketsTyp1 extends Actor{
public RocketsTyp1(){
super(true,"sprites/rocket2.gif");
setVertMirror(true);
typ1[i]=10;}
private void shoot(){
.............
}
public void act(){
...........
}
public int collide(Actor actor1, Actor actor2){
...................
}
}
//<---End class RocketsTyp1--->\\
}