This is the code for my actor in my game.
whenever I try to move is says the actor is out of bounds. for example: Y = 6 should have been less than 5
any help would be appreciated thanks
import greenfoot.*;
import java.awt.Color;
/**
* Write a description of class Mazer here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Mazer extends Actor
{
/**
* Act - do whatever the Mazer wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
World world = getWorld();
Color color = Color.WHITE;
GreenfootImage background = world.getBackground();
if (Greenfoot.isKeyDown("left"))
{
setRotation(180);
if (background.getColorAt(getX() - 7, getY()).equals(Color.WHITE))
{
move(3);
}
}
if (Greenfoot.isKeyDown("up"))
{
setRotation(270);
if (background.getColorAt(getX(), getY() + 7).equals(Color.WHITE))
{
move(3);
}
}
if (Greenfoot.isKeyDown("right"))
{
setRotation(0);
if (background.getColorAt(getX() + 7, getY()).equals(Color.WHITE))
{
move(3);
}
}
if (Greenfoot.isKeyDown("down"))
{
setRotation(90);
if (background.getColorAt(getX(), getY() - 7).equals(Color.WHITE))
{
move(3);
}
}
}
}
