Last active
August 29, 2015 14:14
-
-
Save Madrigal/6725a58a4fa5cf886d9c to your computer and use it in GitHub Desktop.
My strategy for elevator saga http://play.elevatorsaga.com/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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