Skip to content

Commit

Permalink
Rename node vehicle method to remove confusion with path addVehicle m…
Browse files Browse the repository at this point in the history
…ethod
  • Loading branch information
peej committed Jan 21, 2012
1 parent 3f57279 commit 1f1a72e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions traffic.js
Expand Up @@ -27,9 +27,9 @@ Traffic.run = function (canvas, startNodes) {
$.each(startNodes, function () {
Traffic.render(canvas, this);
if (Traffic.phase % this.frequency == 0) {
this.addVehicle({
this.transferVehicle(Traffic.Vehicle.create({
name: "from " + this.name
}); // increment start node
})); // increment start node
}
});
$.each(startNodes, function () {
Expand All @@ -51,7 +51,7 @@ Traffic.render = function (canvas, node) {
if (this.vehicles.length > 0) {
var veh = this.vehicles[0];
if (veh.exitPhase <= Traffic.phase) {
if (this.endNode.addVehicle(veh, this)) {
if (this.endNode.transferVehicle(veh, this)) {
this.removeVehicle();
}
}
Expand Down Expand Up @@ -91,7 +91,7 @@ Traffic.Node = Traffic.extend({
this.paths.push(path);
},

addVehicle: function (veh, fromPath) { // add a vehicle to a path from this node
transferVehicle: function (veh, fromPath) { // transfer a vehicle to a path from this node
veh = veh || Traffic.Vehicle.create();
fromPath = fromPath || {};
if (
Expand Down Expand Up @@ -126,12 +126,16 @@ Traffic.StartNode = Traffic.Node.extend({
});

Traffic.EndNode = Traffic.Node.extend({
addVehicle: function (veh, fromPath) { // exit nodes always have room
transferVehicle: function (veh, fromPath) { // exit nodes always have room
console.log("Vehicle '" + veh.name + "' exits from node '" + this.name + "'");
return true;
}
});

Traffic.PriorityNode = Traffic.Node.extend({

});

Traffic.Path = Traffic.extend({

startNode: null, // node that starts this path
Expand Down

0 comments on commit 1f1a72e

Please sign in to comment.