<html lang="pl">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<title>Gra_przeglądarkowa</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta charset="utf-8">
<style>
canvas{border:#666 1px solid;}
</style>
<script>
function m1(x,y)
{
var canvas = document.getElementById('h1');
var c=canvas.getContext('2d');
c.save();
c.clearRect(0,0,550,400);
c.fillStyle="rgba(0,200,0,1)";
c.fillRect(x,y,50,50);
c.restore();
x+=1;
var loopTimer =setTimeout('m1('+x+','+y+')',30);
}
function stop1()
{
window.stop(m1(x,y));
}
</script>
</head>
<body>
<button onclick="m1(0,0)">Rysuj</button>
<canvas id="h1" width="500" height="500"></canvas>
<button onclick="stop1()">stop</button>
</body>
</html>