I need to make a game for my school project but i just cant fix this
https://www.greenfoot.org/scenarios/31131
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Tussenscherm here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Tussenscherm extends World
{
/**
* Constructor for objects of class Tussenscherm.
*
*/
public Tussenscherm()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1000, 700, 1);
addObject(new Timer(), 1290, 30);
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Tussenscherm here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Tussenscherm extends World
{
/**
* Constructor for objects of class Tussenscherm.
*
*/
public Tussenscherm()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1000, 700, 1);
addObject(new Timer(), 1290, 30);
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Counter here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Counter extends Actor
{
private int totalCount = 0;
public Counter()
{
setImage(new GreenfootImage("0", 20, Color.WHITE, Color.BLACK));
}
public void bumpCount(int amount)
{
totalCount += amount;
setImage(new GreenfootImage("" + totalCount, 20, Color.WHITE, Color.BLACK));
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* A Space ship which shoots at asteroids.
*
* @author Davin McCall
*/
public class Rocket extends Actor
{
private int shotTimer = 0;
/**
* Act - do whatever the Ship wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
shootYourShot();
}
public void shootYourShot() {
if (shotTimer > 0) {
shotTimer = shotTimer - 1;
}
else if (Greenfoot.isKeyDown("space")) {
getWorld().addObject(new Shot(this), getX(), getY());
Greenfoot.playSound("schietgeluid.mp3");
shotTimer = 200; // delay next shot
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class StartKnop here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class StartKnop extends Actor
{
/**
* Act - do whatever the StartKnop wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (Greenfoot.mouseClicked(this))
{
Greenfoot.setWorld(new Space());// Add your action code here.
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Tijdslimiet here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Timer extends Actor
{
//(hoelang duurt de timer? 30 seconden)
private int timer = 55*5;
public void act()
{
// hoe tijd werkt
timer--;
if (timer % 55 == 0) updateImage();
if (timer <=0) Greenfoot.setWorld(new Space2());
}
private void updateImage()
{
// kleur tijd
setImage(new GreenfootImage("Tijd over:" + timer/55, 20, Color.BLACK, Color.WHITE));
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* An Asteroid that flies across the screen.
*/
public class Asteroid extends Actor
{
/**
* Act - do whatever the Asteroid wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
checkEdgeRight();
}
public void checkEdgeRight() {
int xpos = getX() + 1;
if (xpos >= getWorld().getWidth()) {
getWorld().removeObject(this);
}
else {
setLocation(xpos, getY());
}
}
}