I want to make a racing game were the car turns and the background moves in the direction that the car is pointing but i have no idea were to start... Please give help. Thanks.
if(Greenfoot.isKeyDown("up"))
{
setLocation(280, 280);
if(Greenfoot.isKeyDown("left"))
{
turn(-1);
}
if(Greenfoot.isKeyDown("right"))
{
turn(1);
}
move(1);
}
if(Greenfoot.isKeyDown("down"))
{
setLocation(280, 280);
if(Greenfoot.isKeyDown("left"))
{
turn(1);
}
if(Greenfoot.isKeyDown("right"))
{
turn(-1);
}
move(-1);
} if(Greenfoot.isKeyDown("up"))
{
int myX = getX();
int myY = getY();
if(Greenfoot.isKeyDown("up"))
{
Race_Car car = (Race_Car)getWorld().getObjects(Race_Car.class).get(0);
int x = car.getX()-280;
int y = car.getY()-280;
setLocation(myX+x, myY+y);
}
}
if(Greenfoot.isKeyDown("down"))
{
int myX = getX();
int myY = getY();
if(Greenfoot.isKeyDown("down"))
{
Race_Car car = (Race_Car)getWorld().getObjects(Race_Car.class).get(0);
int x = car.getX()-280;
int y = car.getY()-280;
setLocation(myX+x, myY+y);
}
}public void act()
{
Actor car = (Actor)getWorld().getObjects(Race_Car.class).get(0);
setLocation(car.getX()-280, car.getY()-280);
}public void act()
{
Actor car = (Actor)getWorld().getObjects(Race_Car.class).get(0);
setLocation(car.getX()-280, car.getY()-280);
}int x = getX(); int y = getY();
int dx = getX()-x; int dy = getY()-y; Actor track = (Actor)getWorld().getObjects(Track.class).get(0); track.setLocation(track.getX()+dx, track.getY()+dy); setLocation(getX()+dx, getY()+dy);