Business outfitted Bob - collision detection

Hello, I have been working on the Game Dev Project “Business Outfitted Bob”
(https://www.codecademy.com/paths/create-video-games-with-phaser/tracks/game-dev-learn-javascript-basics/modules/game-dev-project-variables-and-conditionals/projects/business-outfitted-bob).

Everything was running fine until I had to add this.endGame () to bobXCoord and bobYCoord, to end the game if the walls are touched. The numbers I was told to assign to it are not making sense to me at all.

Here is what my code looks like:

if (bobXCoord <= 32 || bobXCoord >= 448); {
  this.endGame();
}

if (bobYCoord <= 32 || bobYCoord >= 568); {
  this.endGame();
}

The game just ends as soon as it begins, because these numbers seem off to me. I apologize if this problem is worded incorrectly. Thank you.

Hey @coffeepooch, welcome to the forums!

You have a semi-colon after the if statement and before the curly brace. This prevents the code from working.

1 Like

Thank you so much! Can’t believe I hadn’t noticed that. :sweat:

I thought it had to do with the coordinates, but I understand that better now. Really appreciate you responding!

1 Like

Hey no problem! It’s the tiny little errors that will really kill ya!

1 Like

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.