Awesome game. Not sure if this is a bug in my solution or in game code, but challenge 5 stops randomly after some time. I.e. it never reaches success or fail screen, elevators just stop in the middle of transition doing nothing. Floor buttons work fine, but game time does not progress.
Clicking 'apply' resets the game, but it hangs again after some time.
{
init: function(elevators, floors) {
var onIdle = function(elev){
elev.goToFloor(0);
};
var onFloorButtonPressed = function(elev, floorNum){
elev.goToFloor(floorNum);
}
var onPassingFloor = function(elev, floorNum, direction){
var pressed = elev.getPressedFloors();
if (pressed.length > 0)
{
if (pressed.lastIndexOf(floorNum) > 0)
elevator2.goToFloor(floorNum, true);
}
}
var setUp = function (el){
el.on("idle", function() {
onIdle(el)
});
el.on("floor_button_pressed", function(floorNum) {
onFloorButtonPressed(el, floorNum);
})
el.on("passing_floor", function(floorNum, direction) {
onPassingFloor(el, floorNum, direction);
});
}
setUp(elevators[0]);
setUp(elevators[1]);
setUp(elevators[2]);
setUp(elevators[3]);
},
update: function(dt, elevators, floors) {
// We normally don't need to do anything here
}
}