Last active
October 24, 2019 16:25
-
-
Save garyjoy/8d8d83264bbd398d6ec38a10a293fc27 to your computer and use it in GitHub Desktop.
Elevator Saga 01 - Starter for Ten...
This file contains 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
{ | |
init: function(elevators, floors) { | |
function getElevator() { | |
// Return a random elevator... | |
return elevators[Math.floor(Math.random() * elevators.length)]; | |
} | |
floors.forEach(floor => { | |
floor.on("up_button_pressed", function() { | |
getElevator().goToFloor(floor.floorNum()) | |
}) | |
floor.on("down_button_pressed", function() { | |
getElevator().goToFloor(floor.floorNum()) | |
}) | |
}) | |
elevators.forEach(elevator => { | |
elevator.on("floor_button_pressed", function(floorNum) { | |
elevator.goToFloor(floorNum) | |
}) | |
}) | |
}, | |
update: function(dt, elevators, floors) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should be used as a starting point for your solution. It will pass the first few challenges (not always on the first attempt).
You might consider...