Business Outfitted Bob Project

Hello everyone!

I am having difficulty in completing the “Business Outfitted Bob” project in the phaser.js game dev path:

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

The issue I am having is when I get to step 18, I need to add conditionals that end the game when Bob touches a wall, but when I add the conditionals in, I do something wrong and the Bob sprite does not load in nor the objects or game counter. I just see a gray screen. It is something I am doing with this code, because when I delete it, the game works fine but when I add it the game breaks.

Step 18 code (mine):

if (bobXCoord <= 32 || bobXCoord >= 448) {
this.endgame();
}
if (BobYCoord <= 32 || BobYCoord >= 568 ) {
  this.endgame();
}

I am also having trouble with step 19, where I need to add a variable that resets the game counter when the game ends, but when I add it where I am instructed to do so, I go to start the game and I only get a white screen. Maybe it is connected with the issue I have with step 18 above, but I genuinely don’t know what I am doing wrong with either of these.

Step 19 code (Mine is within the stars):

create() {
    screen = this.add.image(0, 0, 'end').setOrigin(0);
    **let score = 0; }**

Please help. Thanks :slight_smile:

For step 18, check your capitalization of variable names.
For step 19, score is already globally initialized in GameScene.js. You don’t need to initialize it again.

2 Likes