-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.java
More file actions
executable file
·36 lines (30 loc) · 832 Bytes
/
Car.java
File metadata and controls
executable file
·36 lines (30 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* The Car subclass
*/
public class Car extends Vehicle
{
private int xcfsdf;
public Car(VehicleSpawner origin) {
super(origin); // call the superclass' constructor
maxSpeed = 1.5 + ((Math.random() * 30)/5);
speed = maxSpeed;
int z;
followingDistance = 6;
}
public void act()
{
super.act();
}
/**
* When a Car hit's a Pedestrian, it should knock it over
*/
public boolean checkHitPedestrian () {
Pedestrian p = (Pedestrian)getOneObjectAtOffset((int)speed + getImage().getWidth()/2, 0, Pedestrian.class);
if (p != null && p.isAwake()){
p.knockDown();
return true;
}
return false;
}
}