Game Dev Project - Functions and Slope, Mole Unearther

https://www.codecademy.com/paths/create-video-games-with-phaser/tracks/game-dev-learn-javascript-function-and-scope/modules/game-dev-project-functions-and-scope/projects/mole-unearther

This project is absolutly awful, every single time I seem to make progress I get stopped by the very next step, I’m at step 15 and I have no clue how I’m supposed to add a points parameter to Score, I tried

const updateScore = points => {
let score(points);
}

but this just caused the game to vanish, I’ve scoured the previous lessons and they give no indication as to how to attempt this, I don’t understand what I’m expected to do.

The following is the rest of the code that I have in update() upon the vanishing game window:

// periodically checks and handles user input by updating game logic

update() {

if (timeLeft <= 0) {

  // Provided for user

  this.scene.stop('GameScene');

  this.scene.start('EndScene');

}

const updateScore = points => {

  let score(points);

}

// user successfully hit the mole, so reward the user with 5pts

const applyHitReward = () => {

  // display how many points the user will gain

  this.displayRewardText();

  // display the new score to the user

  this.updateScoreText();

};

// user missed the mole, so penalize the user by taking away 5pts

const applyMissPenalty = () => {

  // display how many points the user will lose

  this.displayPenaltyText();

       

  // display the new score to the user

  this.updateScoreText();

};



// will run when any of those keys are pressed. Then, it will distribute rewards and penalties accordingly.

 const onBurrowHit = key => {

    if(key === currentBurrowKey) {

      applyHitReward();

      this.relocateMole();

    } else {

      applyMissPenalty();

    }

    

  }

When you feel stuck, click on the hint. There’s nothing wrong with it.
The step 15 says:

We can create the function the same way as we did for the updateTimer() function, using a named function or arrow function.

Which is:

const updateTimer = () => {
      timeLeft--;
    }

You don’t have to declare score again because you already have it at the top of all the code.
let score = 0;

Your code now looks like this:

const updateScore = points => {
  let score(points);
}

What you need to do is to update the score based on the points argument, so, your code should look something like this:

const updateScore = points => {
score += points;
}
1 Like

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