This game is only a prototype. I am creating a top-down open-world game and I have a plan to make the scenery move whilst the character turns and animates (but doesn't move) . The problem is after a few seconds of the scenery moving in any direction it freezes and won't move any more. Here's my code:
Here's a video showing the problem: This is it
import greenfoot.*;
public class Scenery extends Actor
{
private int step = 5;
public void Move()
{
int y = getY();
int x = getX();
if(Greenfoot.isKeyDown("w")) y += step;
if(Greenfoot.isKeyDown("s")) y -= step;
if(Greenfoot.isKeyDown("a")) x += step;
if(Greenfoot.isKeyDown("d")) x -= step;
setLocation(x, y);
}
public Scenery(int width, int height) {
GreenfootImage image = getImage();
image.scale(width, height);
setImage(image);
}
public void act()
{
Move();
}
}

