Jump to content

High score code for a game


phpuserlogin

Recommended Posts

Hello,

I tried this code in a game, but doesn't do anything.

if(score>highScore){
localStorage.setItem('highScore',score);
var highScore=0, loc=localStorage.getItem('highScore');
if(loc>0)highScore=loc;

The bottom would be added after var variables.

And the top is for the Game over part of the game.

ctx.fillText("High Score: "+HighScore,400,20);
  }

This would go in a Function Check for Hits, at the very end

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...