Help with Mole Unearther Tasks 10-15

This is the project: 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

I am stuck on tasks 10-15 and I have no idea what is incorrect. Currently, I am trying to figure out how to make the keys register and do something to the game. My code:

update() {

    if (timeLeft <= 0) {

      const onBurrowHit=key=>{

        if (Phaser.Input.Keyboard.JustDown(gameState.jKey)) {

onBurrowHit(j)

} else if (Phaser.Input.Keyboard.JustDown(gameState.kKey)) {

onBurrowHit(k)

} else if (Phaser.Input.Keyboard.JustDown(gameState.lKey)) {

onBurrowHit(l)

}

      }

      if (onBurrowHit(j,k,l)) {

        applyHitReward()

        this.relocateMole();

      } else {

        applyMissPenalty()

      }

Please tell me what is wrong with my code. I would greatly appreciate it. Thanks in advance.

Hi!

Can you try re-pasting your code pressing the </> button before pasting so that it formats properly?

At this point, even without looking at the code, I would put a simple statement check for the key presses eg: console.log('x key was pressed'). Then when you’re running your file, you check the console directly and see if it’s coming out. If not, always remember you can interact with the console “live” and debug accordingly from there.

Okay I will re-post it. But how do I check live console?
Only question

Right or control click on the browser, click inspect element, look for the console tab. You may need to resize it so that it’s more comfortable to use. I personally like to have projects away from the CC environment when debugging so I don’t get any extraneous messages from CC, so there’s that too.

Yeah I don’t see anything. When I press j, k, l, nothing happens in the console

Then you have to debug your key event handlers. MDN is a good resource, I don’t know what methods you’re using, so you should look them up more specifically if these linked ones don’t help.

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