I need to make a game for my school project but i just cant fix this
https://www.greenfoot.org/scenarios/31131
![Twitter](/assets/twitter-4e19209ef84344ee0c433f4c7bad8d49.png)
![Twitter.hover](/assets/twitter.hover-1fb19a5bafc50deace8f88eaec867845.png)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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 ); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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 ); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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)); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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 } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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. } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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)); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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()); } } } |