danpost wrote...
RandomGuy wrote...
It still says identifier expected?import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Bullet here. * * @author (your name) * @version (a version number or a date) */ public class Bullet extends Actor { /** * Act - do whatever the Bullet wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public Bullet() { } public void act() { move(6); if (isAtEdge() || collidesWithZombie()) { getWorld().removeObject(this); } collidesWithZombie(); System.out.println("Bullet removed from hitting "+(isAtEdge() ? "edge" : "zombie")+"."); } private void updateHealth() { } private boolean collidesWithZombie() { if( ! isTouching(Zombies.class)) return false; { Greenfoot.playSound("Gunshot.mp3"); removeTouching(Zombies.class); Counter counter = (Counter) getWorld().getObjects(Counter.class).get(0); counter.add(1); return true; } } private void repeat() { } }
import greenfoot.*; //(Mythic2,Explorer) // (World,Explorer, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Mythic2 here. * * @author (your name) * @version (a version number or a date) */ public class Mythic2 extends World { private Healthbar healthbar = new Healthbar(); long lastAdded = System.currentTimeMillis(); private Counter counter = new Counter(); /** * Constructor for objects of class Mythic2. * */ public Mythic2() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); prepare(); spawn(); updateHealth(); } public void updateHealth() { if (healthbar.getHealth()<=0) { setBackground("gameover.png"); Greenfoot.stop(); } } private void prepare() { Explorer Explorer = new Explorer(); addObject(Explorer, 86, 206); } public Healthbar getHealthBar() { return healthbar; } public void spawn() { Zombies Zombies = new Zombies(); addObject(new Zombies(), 515, 205); Counter Counter = new Counter(); addObject(Counter, 50, 41); Healthbar Healthbar = new Healthbar(); addObject(Healthbar, 530, 33); } public void removeObject(Actor actor) { super.removeObject(actor); if (actor instanceof Zombies) addObject(new Zombies(), 515, 205); } }