Game Dev Project - Functions and Scope - Mole unearther

Link for 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

Hi there,
I’m stuck on step 5 for this project. I’ve set up the variables as per instructions. However, after I saved my code and ran the program, I can’t see the timeleft and score board on the top left corner. It just appears with a salmon pink background with J, K, L and a pale orange rectangle box on the top left corner. Is there something to do with my chrome setting?

The first 3 lines are the codes I added, and the rest of the codes are unedited from the project.

1 const timeLeft = 30;
2 const score = 0;
3 const isPaused = false;
4 // Stores the current “key” location of the mole
5 let currentBurrowKey;
6
7 const gameState = {};
8
9 class GameScene extends Phaser.Scene {

Much appreciated if anyone could give me some directions…

Many thanks in advance!

4 Likes

Hey @cssace70814!

Should these variables be constant if you’re gonna change 'em?

1 Like

Thanks Steven for the reply. Still doesn’t work after I changed variables to constant.
I copied and pasted the solution code still doesn’t work. I know I’m not suppose to do that (cheating!) but I just want to check if my coding logic is wrong or there’s something to do with the setting on my chrome. Turns out that it’s the later. It would be great if you or anyone else have any ideas on what I should do next??

Hmm, I would recommend trying it in a different browser (such as firefox) so you can make sure that it isn’t just a problem for that browser.

Can you send a screenshot as well of your unexpected result?

Interestingly, the game won’t run on my Chrome and IE browsers

Here is the screenshot

It’ll run on firefox, but the time and score board still not showing up on the top left corner.
Here is the solution code
Solution code for mole unearther

Check your learning environment… Does it have all these files?

You can access it by clicking the folder icon next to the file name.

Thanks Steven. Yes, all files are there. Still doesn’t work on Chrome. To be honest, I’ve given up. I’ll use Firefox from now on for Codecademy gaming projects. Thanks a lot for all the suggestions you’ve given me!

1 Like

Hey,

I’m having the same problems for this exercise. I tried copy/pasting the solution code and comparing that with the code from the working version, and it still doesn’t run like the working version. These Phaser Projects are new and I’m guessing that CC will be on it soon.

Hello,

I am getting this same issue in both firefox and chrome. Also Codecademy does not work on internet explorer. I am not sure how I am supposed to fix this issue. Any ideas?

Do you have the latest version of all the web browsers?

Yep. I have no current updates for chrome and firefox was just installed on my computer. The weirdest part is that if I restart the project the game pulls up the burrows no problem but the second I put in the first variable it gives that pink background.

I got it figured out there was an issue with one of my variables. Man learning how to code and keeping track of every character is a challenge :rofl: :sweat_smile:

1 Like

It happened the same to me and I use let to declare de variables. Im using safari.

Did it display the information of timeLeft on firefox?

I’m having the same problem on google chrome

How do I bump this? I’m having the same issue in Chrome. I’m sure it’s not the code, and I can’t get the timer to show up.

I tried blocking my adblocker thinking that might hvae been the issue, but alas still no results.

Please help! Thanks.

Hey @designplayer38298, welcome to the forums.

Can you please post your code? We’ll double check for you just to make sure.

Hi @stevencopeland - thanks for the message. Below is the screenshot from my page. To make sure everything loaded properly, I reset the project multpile times but had the same issue.

I’m a huge fan of CodeCademy, this is the first real issue I’ve had with the program. The Python 3 course was great.

Hi I am not able to get the add score section work, when I select the correct letter it still shows -5 near the score nothing I do can get a +5 to show.

I am also having trouble with the unpause section as I have done the else statement correctly but it doesn’t seem to load the page when I do so something must be wrong in the code but I’m not sure what.

let updateScore = (points) => {
  //score += ;
}

	// user successfully hit the mole, so reward the user with 5pts
	const applyHitReward = () => {
		// display how many points the user will gain
		this.displayRewardText();
  updateScore();
  // 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();
  updateScore();
  // display the new score to the user
		this.updateScoreText();
	}

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

const togglePause = () => {
  if (isPaused === false) {
    isPaused = true;
    this.displayPauseScreen();
} else {
  isPaused = false;
  this.removePauseScreen();
}

}

	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’);
}
}

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

togglePause();
}
}

I cannot seem to figure out why the +5 wont show when the correct key is pressed and how to update the score