I still think Python is the most straightforward to learn, even though the whitespace constantly catches beginners out too.
I still think Python is the most straightforward to learn, even though the whitespace constantly catches beginners out too.
What's going on there is just that the robot can only enqueue a single action for the tick. So calling multiple actions will just overwrite the slot.
It's an implementation detail of the game. Maybe it's tougher for beginners or not the best trade-off, but it doesn't have much to do with Javascript
robot.action = { action: 'jump' };
robot.action = { action: 'move', amount: 4 };
etc.
Or if you want to keep the action creators: robot.action = robot.jump();
robot.action = robot.move(4);
Which makes it obvious that there can only be a single action per loop call. { jump: true, move: 4, shoot: true }
Making the user increment a nonce and use the remainder operator just to do multiple actions simultaneously is pretty heavy. function loop(robot){
// your code here
robot.move(1)
robot.jump()
}I bet jump() has something like `if (robot.touchingFloor) { action = 'jump'; }` which makes your code work because it doesn't overwrite the robot action if it can't actually jump.
Switch the order of actions and you'll see the robot never jumps because its action gets overwritten (as stated in the instructions tab).
EDIT: Here it is:
https://github.com/reaalkhalil/JSRobot/blob/478848147a080d8b...