hello,
im making a game with a soccerfield in it but i have a problem. I need a object to stay between the lines otherwise the game wont be as it used to be. which code can i use to keep this object between the lines? The object to stay between the line can only move up and down. This is the code im using for the object to move up and down.
public void act()
{
if (Greenfoot.isKeyDown("q")) {
setLocation(getX(), getY()-30);
}
if (Greenfoot.isKeyDown("a")) {
setLocation(getX(), getY()+30);
}
}
can i get some help?

