import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class Space here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Space extends World
{
private static final int WIDTH = 640;
private static final int HEIGHT = 480;
private static final int ROW_LENGTH = 500;
private static final int FIRING = 30;
private int actcounter = 0;
/**
* Constructor for objects of class Space.
*
*/
public Space()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(WIDTH, HEIGHT, 1);
prepare();
}
/**
* Prepare the world for the start of the program. That is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
Shooter shooter = new Shooter();
addObject(shooter, 320, 420);
for(int i=0; i<11; i++) {
addObject(new Spaceinvader3(), (WIDTH-ROW_LENGTH)/2+i*ROW_LENGTH/10, 50);
}
}
public void act()
{
actcounter++;
if (actcounter > FIRING) {
List invaders = getObjects(Spaceinvader3.class);
if (!Spaceinvader3.isEmpty()) {
int number_of_invaders = Spaceinvader3.size();
int i = Greentfoot.getRandomNumber(number_of_invaders);
Spaceinvader3 ramdominvader = (Spaceinvader3)invader.get(1);
}
actcounter = 0;
}
}
}