chal2
This commit is contained in:
30
challenge2.md
Normal file
30
challenge2.md
Normal file
@@ -0,0 +1,30 @@
|
||||
Same as level 1
|
||||
|
||||
```
|
||||
{
|
||||
init: function(elevators, floors) {
|
||||
var elevator = elevators[0];
|
||||
|
||||
elevator.on("idle", function() {
|
||||
// idle in the middle for the shortest way
|
||||
elevator.goToFloor(1);
|
||||
});
|
||||
elevator.on("floor_button_pressed", function(floorNum) { elevator.goToFloor(floorNum);} );
|
||||
for(const floor of floors){
|
||||
floor.on("up_button_pressed",
|
||||
function() {
|
||||
elevator.goToFloor(floor.level);
|
||||
})
|
||||
floor.on("down_button_pressed",
|
||||
function() {
|
||||
elevator.goToFloor(floor.level);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
update: function(dt, elevators, floors) {
|
||||
// We normally don't need to do anything here
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user