aboutsummaryrefslogtreecommitdiff
path: root/Week14 Route 66/src/OO14route66/Car.java
diff options
context:
space:
mode:
Diffstat (limited to 'Week14 Route 66/src/OO14route66/Car.java')
-rw-r--r--Week14 Route 66/src/OO14route66/Car.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/Week14 Route 66/src/OO14route66/Car.java b/Week14 Route 66/src/OO14route66/Car.java
index 97d7b33..c12291a 100644
--- a/Week14 Route 66/src/OO14route66/Car.java
+++ b/Week14 Route 66/src/OO14route66/Car.java
@@ -1,7 +1,6 @@
package OO14route66;
import com.camilstaps.route66.Driver;
-import com.camilstaps.route66.Overviewer;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
@@ -47,9 +46,8 @@ public class Car {
direction = Direction.intToDirection(number);
location = RoadView.WINDOWSIZE - 2 - (number/Model.DIRECTIONS) * (CARLENGTH + MINCARSPACE);
colour = carColours[number % carColours.length];
- driver = new Driver(this);
+ driver = new Driver(this, model);
this.model = model;
- Overviewer.getInstance().hello(this);
}
/**
@@ -97,8 +95,17 @@ public class Car {
*/
public void step() {
location = getNewLocation();
+ //System.err.println("Car ");
model.update();
}
+
+ public boolean isInFrontOfCrossing() {
+ return location < RoadView.getStartCrossing() && getNewLocation() >= RoadView.getStartCrossing();
+ }
+
+ public boolean isOnCrossing() {
+ return location > RoadView.getStartCrossing() && location - CARLENGTH < RoadView.getEndCrossing();
+ }
/**
* Paint this car