Hi!
I’m trying to make a very simple high score system in an HTML5/Javascript game that simply stores the score value in an array if it’s value is more than the previous high score and does not store it’s value in the array otherwise. I can get it to either continuously count up along with the current score and then reset to zero, but that doesn’t help much. Anyone have ideas for how to do this? PS I don’t want local storage or anything. Just a super simple system that remembers your high score for the current session until you get a higher one.
here is the code for the arrays I’m using. astrosCaught is the current score. It increments by on hit detection via astrosCaught++.
var highscore = [0];
var scoreKeeper = [];
if (astrosCaught > highscore[0])
{
highscore.unshift(astrosCaught);
}
else {scoreKeeper.unshift(highscore[0]);};
here is the code for the text
ctx.fillText("high score:" + scoreKeeper[0], 10, 64);
the project is located at http://dtc-wsuv.org/rhanrahan16/final477/
let me know if you need more information, I’m pretty new to Javascript and these forums!
-Ryan