User Tools

Site Tools


javascript:labirintas

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
javascript:labirintas [2016/12/05 21:15] – aistisjavascript:labirintas [2016/12/06 00:10] (current) – aistis
Line 21: Line 21:
 function refresh(){ function refresh(){
  ctx.clearRect(0, 0, c.width, c.height);  ctx.clearRect(0, 0, c.width, c.height);
-    ctx.drawImage(img,0,0,600,600);  + ctx.drawImage(img,0,0,600,600);  
-    ctx.beginPath();+ ctx.beginPath();
  ctx.arc(x,y,1,0,2*Math.PI);  ctx.arc(x,y,1,0,2*Math.PI);
  ctx.stroke();  ctx.stroke();
Line 29: Line 29:
 function checkKey(e) { function checkKey(e) {
  
-    e = e || window.event;+ e = e || window.event;
  
-    if (e.keyCode == '38') y = y - step; + if (e.keyCode == '38') y = y - step; 
-    else if (e.keyCode == '40') y = y + step; + else if (e.keyCode == '40') y = y + step; 
-    else if (e.keyCode == '37') x = x - step; + else if (e.keyCode == '37') x = x - step; 
-    else if (e.keyCode == '39') x = x + step;+ else if (e.keyCode == '39') x = x + step;
  
-    if (x < 0) x = 0; + if (x < 0) x = 0; 
-    if (y < 0) y = 0; + if (y < 0) y = 0; 
-    if (x > 600) x = 600; + if (x > 600) x = 600; 
-    if (y > 600) y = 600;+ if (y > 600) y = 600;
  refresh();  refresh();
 }</code> }</code>
javascript/labirintas.1480965300.txt.gz · Last modified: by aistis