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 void act() { { move(20); Explosion(); if (atWorldEdge()) { this.getWorld().removeObject(this); } } } public boolean atWorldEdge() { if(getX() < 20 || getX() > getWorld().getWidth() - 20) return true; if(getY() < 20 || getY() > getWorld().getHeight() - 20) return true; else return false; } public void Explosion() { boolean kill = true; if(kill) if (isTouching(Gegner.class)) { kill = false; //removeTouching(Gegner.class); Levels world = (Levels)getWorld(); getWorld().addObject(new Splode(), getX(), getY()); //getWorld().removeObject(this); Greenfoot.playSound("Explosion.mp3"); } } }