Elevator Saga - Browser game with js-like programming tasks https://play.elevatorsaga.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
556 B

2 years ago
  1. ## v0.1 working
  2. ```js
  3. {
  4. init: function(elevators, floors) {
  5. var elevator = elevators[0]; // Let's use the first elevator
  6. // Whenever the elevator is idle (has no more queued destinations) ...
  7. elevator.on("idle", function() {
  8. // let's go to all the floors (or did we forget one?)
  9. elevator.goToFloor(0);
  10. elevator.goToFloor(1);
  11. elevator.goToFloor(2);
  12. });
  13. },
  14. update: function(dt, elevators, floors) {
  15. // We normally don't need to do anything here
  16. }
  17. }
  18. ```