c= document.getElementById('c');g= c.getContext('2d');
setInterval(ris,125);
mapClet=50;
mapCol=["#ff00ff","#ff0000","#00ff00","#0000ff"];
map=[
1,1,3,1,3,1,1,1,
1,1,3,1,3,1,1,1,
1,1,3,1,3,1,1,1,
1,1,3,1,3,1,1,1,
3,1,1,1,1,1,3,1,
1,3,1,1,1,3,1,1,
1,1,3,3,3,1,1,1,
1,1,1,1,1,1,1,1
];
xq=0;yq=0;
function ris(){
switch (key){
case 37: xq--;break;
case 38: yq--;break;
case 39: xq++;break;
case 40: yq++;break;
}
g.clearRect(0,0,512,512);
for(n=0;n<64;n++){
x=n&7;y=n>>3;rx=Math.random()*25;ry=Math.random()*2;rs=Math.random()*2;
x=(x+xq)&7;y=(y+yq)&7;
g.fillStyle=mapCol[map[n]];
g.fillRect(x*mapClet+rx,y*mapClet+ry,mapClet-5-rs,mapClet-5-rs);
}
}
document.onkeydown = keyDn; document.onkeyup = keyUp; key=0;
function keyDn(e) {key = e.which; /*alert(key);*/ }
function keyUp(e) {key = 0;}
скроллер экрана.