Hey, im doing a school project and i chose to do a racing game, i have made a car with basic controls (turn left/right, move forwards/backwards) but i want to limit how much the car turns.
The car is facing right, i want it to turn left 45 degrees and right 45 degrees (im guessing the angle i havent tried it out yet). Also, please tell me how to change the angle incase i want to.
Please Help with this (Hopefully its danpost :) )
Thank You
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class NSX4 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class NSX4 extends Actor
{
/**
* Act - do whatever the NSX4 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (Greenfoot.isKeyDown("left"))
{
turn(-5);
}
if (Greenfoot.isKeyDown("right"))
{
turn(5);
}
if (Greenfoot.isKeyDown("up"))
{
move(5);
}
if (Greenfoot.isKeyDown("down"))
{
move(-5);
}
}
}


