html - How would I go about making a local highscore table for my game?(Javascript) -


well, made quick whack-a-mole game in javascript. have counter counts number of clicks on mole. animate function

    function animate0(pos) {     pos %= urls.length;     var animation0 = document.getelementbyid('animation0');     var counter = document.getelementbyid('counter');     animation0.src = urls[pos];     if (pos == 1) { // make onclick when have image         animation0.onclick = function() {             counter.innerhtml = parseint(counter.innerhtml) + 1;         }     }     else {         animation0.onclick = function() {             //do nothing         }     }     settimeout(function() {         animate0(++pos);     }, (math.random()*500) + 1000); } 

i display counter via code,

<div id='counter'>0</div> 

although un-related, how display animation,

<img id='animation0' src ='http://i51.tinypic.com/sxheeo.gif'/> 

i can't figure out how make local computer highscore table(perhaps 5 or spots scores). help? thanks, steven

use cookies or html5 databases.

a bad cookie example:
setcookie('highscores', '100,120,130,140,150')

and later

var highscores = getcookie('highscores').split(',') //now contains [100,120...] 

alternatively, store json object string if wanted store names , other data. data format might this:

[{name: 'stk', score: 1100}, {name: 'ass', score:'1000'}] 

you need use json handling library (in jquery, or else) stringify array , parse later.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -