import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* 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()
{
if (Greenfoot.isKeyDown("w"))
{
//Car should move forward and stop if it hits a wall
move(3);
}
if (Greenfoot.isKeyDown("a"))
{
//Car should turn to the right and stop if it hits a wall
turn(3);
}
if (Greenfoot.isKeyDown("s"))
{
//Car should turn to the left and stop if it hits a wall
turn(-3);
}
if (Greenfoot.isKeyDown("z"))
{
//Car should move backward and stop if it hits a wall
move(-3);
}
}
public void canMove()
{
if (isTouching(wall1.class))
{
//stop the game if the car hits the wall
}
}
}