I have a person who is shooting a gun. When you are running left it shoots left.
When you are running right it shoots right.
When I have him standing still, he shoots up.
I want to make it so that when you are stopped it shoots in the direction you were last facing. So if I was running left, and stopped, and shot, it would shoot left. If I was running right, stopped, and shot, it would shoot right.
("direction" is the horizontal movement, + is right, - is left.)
("directions" is the vertical movement, + is down, - is up.)
if (Greenfoot.isKeyDown("left"))
{
direction = -50;
directions = 0;
}
if (Greenfoot.isKeyDown("right"))
{
direction = +50;
directions = 0;
}
if (!right && !left && !up && !down)
{
if (Greenfoot.isKeyDown("space"))
{
direction = 0;
directions = -50;
}
