Skip to content

Instantly share code, notes, and snippets.

@bgnori
Created August 10, 2016 14:18
Show Gist options
  • Save bgnori/485bc2b383773f0c44a6262e0f679652 to your computer and use it in GitHub Desktop.
Save bgnori/485bc2b383773f0c44a6262e0f679652 to your computer and use it in GitHub Desktop.
{
init: function(elevators, floors) {
var A = elevators[0];
A.on("idle", function() {
A.goToFloor(0);
});
A.on("floor_button_pressed", function(floorNum) {
if (A.currentFloor < floorNum) {
A.goingUpIndicator(true)
A.goingDownIndicator(false)
};
if (A.currentFloor > floorNum) {
A.goingUpIndicator(false)
A.goingDownIndicator(true)
};
A.goToFloor(floorNum);
});
for (var i = 0; i < floors.length; i++) {
var f = floors[i];
f.on("up_button_pressed", function() {
A.goToFloor(f.floorNum())
});
f.on("down_button_pressed", function() {
A.goToFloor(f.floorNum())
});
};
},
update: function(dt, elevators, floors) {
// We normally don't need to do anything here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment