Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Madrigal
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Madrigal/6725a58a4fa5cf886d9c to your computer and use it in GitHub Desktop.
Save Madrigal/6725a58a4fa5cf886d9c to your computer and use it in GitHub Desktop.
My strategy for elevator saga http://play.elevatorsaga.com/
// The only small improvement from challange #3 was
// manipulating the elevator light
{
init: function(elevators, floors) {
elevators.forEach(function(elevator){
elevator.on("floor_button_pressed", function(floorNum) {
elevator.goToFloor(floorNum);
});
floors.forEach(function(floor) {
floor.on("up_button_pressed", function() {
elevator.goToFloor(floor.floorNum());
elevator.goingUpIndicator(true);
elevator.goingDownIndicator(true);
});
floor.on("down_button_pressed", function() {
elevator.goToFloor(floor.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