javascript animation effect time interval -
there falling word, , store positions(x,y) , value separate arrays, , if type specific word, remove values in 3 arrays.
i set interval time 800, problem deletion of word corresponds interval time rather deletes following word.
i think because draw() function under update, under influence of interval time, i'm not sure how maintain draw of contents , erase after made input.
var intervaltime = 800; setinterval(update, intervaltime); //appearance interval function dokey (keypressed) { if (window.event.keycode === 13) { //if pressed enter var submission = document.getelementbyid('inputbox').value; var result = checkletter(submission); if (result > -1) { //value deletion alpha.splice(result, 1); //positions deletion listx.splice(result, 1); listy.splice(result, 1); increasescore('score'); } else { console.log("this error"); } document.getelementbyid('inputbox').value = ''; //return first step } } function draw() { (i = 0; < alpha.length; i++) { listy[i] += spdy; ctx.filltext(alpha[i],listx[i],listy[i]); } } function update() { if (document.getelementbyid('life').innerhtml == 0) { alpha = [] listx = [] listy = [] console.log("fail"); endofthegame(); } else { increaselevel(); //console.log(alpha); //console.log(listx); //console.log(listy); spdy = 50 + 5*(document.getelementbyid('score').innerhtml/10);//speed lifededuction() getletter(); ctx.clearrect(0,0,500,500); draw(); } }
you can call draw() function dokey() function ctx.clearrect(0,0,500,500); called before redraw screen. way screen updates other parts of update() function not execute.
Comments
Post a Comment