Doing a school porject, I need the car to reach the bottom of the screen then disappear then return to the top as another color to simulate the illusion of traffic. Then the car must turn 90 degrees and then return next to it as another car. I have the car moving down so far here is the car actor class code.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Car here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Car extends Actor
{
/**
* Act - do whatever the Car wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(5);
turnTowards(600,600);
lookforPlayer();
}
public void move()
{
move(5);
turn(180);
}
public void turnTowards()
{
setRotation(90);
}
public void lookforPlayer()
{
if ( isTouching(Player.class) )
{
removeTouching(Player.class);
Greenfoot.playSound("splat.mp3");
Greenfoot.stop();
}
}
}