Loop does not restart after end of level

I’m having another issue with this game in that after the player dodges the first set of obstacles, the game stops and the loop does not repeat. I don’t believe it’s crashing because it’s very consistent, as soon as the squisher sprites either squish the player or touch each other, the game simply stops running.

For debugging convenience, I’ve set a ton of console.log statements (slows the game down a whole lot) and I remixed the project so that the game automatically starts and the player automatically escapes from the trap.

What I expect to happen: If the player dodges or gets caught in the trap, the loop should continue. I even tried adding a new level in case it was getting stuck inside of the levelOne() function somehow.

What actually happens: The game stops running altogether as soon as the squisher sprites touch each other or both are touching Kurt.

What I’ve tried: I added a bunch of console.log statements to observe that all functions are reached successfully, and that the end of the loop is reached successfully, but the loop does not restart. I also tried adding the next level in case the program flow was somehow getting stuck inside the levelOne() function. levelTwo() starts successfully but the loop does not continue, as the player cannot move after the level is complete.

Hi @mzima,

Fun game. I am not super clear as to what “loop” you are wanting to continue. Are you wanting the squishers to start over?

If yes, in your current code, if the squishers are touching, they stop moving and then the level is increased to level 2 which should run the function but I believe the code is never leaving the if statement because they are always touching. Try moving the positions of the squishers inside the if statement after the level is increased. I also added velocity for the squishers to level 2. It worked for me here - see if this is what you were looking for?

If the squisher movement is not what you were looking for, give us some more detail.

Good luck!
~Michelle

1 Like