I have created a scenario in greenfoot but it is not fully not complete, so I need help with one last thing.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class GameOver here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class GameOver extends Actor
{
/**
* Act - do whatever the GameOver wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setImage(new GreenfootImage("Game Over", 48, Color.PINK, Color.YELLOW));
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Zyxian here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Zyxian extends Actor
{
/**
* Act - do whatever the Zyxian wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(4);
if (Greenfoot.isKeyDown("Left"))
{
turn(-3);
}
if (Greenfoot.isKeyDown("Right"))
{
turn(3);
}
Actor Villian;
Villian = getOneObjectAtOffset(0,0,Villian.class);
if(Villian!=null)
{
TheHouse thehouse = (TheHouse)getWorld();
thehouse.removeObject(Villian);
Greenfoot.playSound("Scream.wav");
Counter counter = thehouse.getCounter();
counter.bumpCount(5);
}
Actor Border = getOneIntersectingObject(Border.class);
if (Border != null)
{
World TheHouse = getWorld();
GameOver gameover = new GameOver();
Greenfoot.playSound("Bomb.wav");
TheHouse.addObject(gameover, TheHouse.getWidth()/2, TheHouse.getHeight()/2);
TheHouse.removeObject(this);
}
}
}
import greenfoot.*;
public class Donald_Trump extends Actor
{
public Donald_Trump()
{
GreenfootImage image = getImage();
image.scale(image.getWidth() - 150, image.getHeight() - 120);
setImage(image);
}
public void act()
{
move(2);
if (Greenfoot.getRandomNumber(100) < 10)
{
turn(Greenfoot.getRandomNumber(90) - 45);
}
if (getX() <= 5 || getX() >= getWorld().getWidth() - 5)
{
turn(180);
}
if (getY() <= 5 || getY() >= getWorld().getHeight() - 5)
{
turn(180);
}
Actor Zyxian = getOneIntersectingObject(Zyxian.class);
if (Zyxian != null)
{
World TheHouse = getWorld();
GameOver gameover = new GameOver();
Greenfoot.playSound("Laugh.wav");
Greenfoot.playSound("Bomb.wav");
TheHouse.addObject(gameover, TheHouse.getWidth()/2, TheHouse.getHeight()/2);
TheHouse.removeObject(Zyxian);
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Zyxian here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Zyxian extends Actor
{
/**
* Act - do whatever the Zyxian wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(4);
if (Greenfoot.isKeyDown("Left"))
{
turn(-3);
}
if (Greenfoot.isKeyDown("Right"))
{
turn(3);
}
Actor Villian;
Villian = getOneObjectAtOffset(0,0,Villian.class);
if(Villian!=null)
{
TheHouse thehouse = (TheHouse)getWorld();
thehouse.removeObject(Villian);
Greenfoot.playSound("Scream.wav");
Counter counter = thehouse.getCounter();
counter.bumpCount(5);
}
Actor Border = getOneIntersectingObject(Border.class);
if (Border != null)
{
World TheHouse = getWorld();
GameOver gameover = new GameOver();
Greenfoot.playSound("Bomb.wav");
TheHouse.addObject(gameover, TheHouse.getWidth()/2, TheHouse.getHeight()/2);
TheHouse.removeObject(this);
Greenfoot.stop();
}
}
}