Mole unearther step 9 handling keyboard input

Hi im having a very hard time getting through Mole unearther step 9 calling my function for onBurrowHit. I’ll post my code below.

 const onBurrowHit = key => {
  
	if (isPaused === false) {
		// check each burrow's location if the user is hitting the corresponding key
		// and run the handler to determine if user should get a reward or penalty
  if (currentBurrowKey === key) {
    applyHitReward()
    this.relocateMole()
  } else {
    applyMissPenalty()
  }
		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 (key === currentBurrowKey) {
    applyHitReward()
    this.relocateMole();
  } else {
    applyMissPenalty();
  }
}

};

It looks like some of your code is out of order. The isPaused if statement is in the middle of your onBurrowHunt function and it should be separate and below it. Mine looks like this and it works:

    const onBurrowHit = (key) => {
      if (key === currentBurrowKey) {
        applyHitReward();
        this.relocateMole();
      } else {
        applyMissPenalty();
      }
  }

		if (isPaused === false) {
			// check each burrow's location if the user is hitting the corresponding key
			// and run the handler to determine if user should get a reward or penalty
			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');
			}
1 Like

Emtron, yours really helped! Thanks a lot!

This helped me, thank you :slight_smile: