This site requires JavaScript, please enable it in your browser!
Greenfoot back
Applez
Applez wrote ...

2018/5/5

Turn Actor While moving in x axis

Applez Applez

2018/5/5

#
I'm making a racing game and want to make the car look like its switching lanes, i want it to turn right but still move in the X axis. I've tried something like this and it turns the car but the car moves to its right, in other words, the car is doing full circles.
if (Greenfoot.isKeyDown("left") && getRotation() != 340)
{
    turn (-5);
    move(-5);
}
if (Greenfoot.isKeyDown("right") && getRotation() != 20)
{
    turn(5);
    move(5); 
}
I want the car to be moving in the X axis (West to east and vice versa) no matter which way the car is facing. I've also tried
setLocation(getY(), getX()+5);
but the car glitches out and appears as 2 images. Thanks in Advance.
You need to login to post a reply.