Hi!
I am currently trying to make a mouse-style shooting game, however I have run into an issue. Every time a bullet hits a wall or enemy, the game pauses, and the error terminal pops up.
The error i get is in the bullet code, at line 13.
Here is the bullet code:
Thanks!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Bullet extends Actor
{
public void act()
{
move(6);
checkBoundaries();
kill();
}
public void kill() {
Actor enemy = getOneIntersectingObject(Enemy.class);
if(enemy != null) {
getWorld().removeObject(enemy);
getWorld().removeObject(this);
}
}
public void checkBoundaries() {
if(getX() > getWorld().getWidth() - 3)
getWorld().removeObject(this);
else if(getX() < 3)
getWorld().removeObject(this);
else if(getY() > getWorld().getHeight() - 3)
getWorld().removeObject(this);
else if(getY() < 3)
getWorld().removeObject(this);
}
}
