I am trying to make the actor face the mouse pointer by turnTowards mouse pointer to aim when the mouse pointer is moved. However the actor only rotates and points at the mouse pointer when the mouse pointer is moving, if the mouse pointer stops moving then the actor returns to its default position, I am basically trying remake diep.io, if you've heard of it, pls reply as soon as possible. Here is the code sofare:
import greenfoot.*;
public class tank extends Actor
{
public void act()
{
setRotation(90);
if (Greenfoot.isKeyDown("w")){
move(-2);
}
if (Greenfoot.isKeyDown("s")){
move(2);
}
setRotation(0);
if (Greenfoot.isKeyDown("d")){
move(2);
}
if (Greenfoot.isKeyDown("a")){
move(-2);
}
if(Greenfoot.mouseMoved(null))
{
MouseInfo mouse = Greenfoot.getMouseInfo();
turnTowards(mouse.getX(),mouse.getY());
}
}
}

