So, I can turn left or right while moving and shooting, but for whatever reason there is an odd exception. I made the controls support WASD and the arrow keys, but it won't let me turn left while moving and shooting. What makes this stranger is it will work if using WASD, but it will not work with the arrow keys. My code only uses "left", "a", and "space" one time each. Left and a are together in an or statement structured exactly like my other or statements, and space is used to fire. To recap, I can normally turn, move, and fire at the same time but it does not work while using the left key.
(squirrel is supposed to fire lasers, I am a strange person)
public class Squirrel extends Actor
{
private int load;
public void act()
{
if(Greenfoot.isKeyDown("a")||Greenfoot.isKeyDown("left"))
{
turn(-4);
}
if(Greenfoot.isKeyDown("d")||Greenfoot.isKeyDown("right"))
{
turn(4);
}
if(Greenfoot.isKeyDown("w")||Greenfoot.isKeyDown("up"))
{
move(4);
}
if(Greenfoot.isKeyDown("s")||Greenfoot.isKeyDown("down"))
{
move(-4);
}
if(Greenfoot.isKeyDown("space"))
{
if(load==20)
{
LaserStart LaserStart= new LaserStart();
LaserStart.setRotation(getRotation());
getWorld().addObject(LaserStart,getX(),getY());
load=0;
}
}
if(load<20)
{
load++;
}
if(Greenfoot.isKeyDown("e"))
{
Laser Laser= new Laser();
Laser.setRotation(getRotation());
getWorld().addObject(Laser,getX(),getY());
turn(12);
}
}
public Squirrel()
{
load=20;
}
}
