when i shoot a space invader and when i get shot it has a slight delay so you can actually see the damagedimage and also i think it gives it gives a retro vibe, one problem is that when my ufo goes atop of the screen it has a 12 second sound clip playing but the delay doesnt pause it so if i hit a bunch of space invaders within the 12 seconds the sound clip will finish way before the ufo gets to the other end of the screen.
i am using Greenfoot.delay(); for the delay
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Space here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Space extends World
{
/**
* Constructor for objects of class Space.
*
*/
GreenfootSound ufo = new GreenfootSound("ufo.wav");
public Space()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(800, 600, 1);
addObject (gameover, 400, 300);
addObject (lifeboard, 500, 20);
addObject (scoreboard, 100, 20);
addObject (new Player(), 400, 550);
addObject (new Invaders(), 0, 0);
addObject (new Barrier1(), 200, 475);
addObject (new Barrier2(), 400, 475);
addObject (new Barrier3(), 600, 475);
setPaintOrder(GameOver.class,Player.class);
}
public void act()
{
if(getObjects(UFO.class).size() == 0)
{
ufo.stop();
if(Greenfoot.getRandomNumber(3000) == 1500)
{
addObject(new UFO(), 0, 50);
ufo.play();
return;
}
}
}
public Scoreboard scoreboard = new Scoreboard();
public Lifeboard lifeboard = new Lifeboard();
public GameOver gameover = new GameOver();
}
