-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09jump.html
41 lines (33 loc) · 936 Bytes
/
09jump.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<canvas id='c'></canvas>
<script>
var c = document.getElementById('c').getContext('2d');
var k = 0; // begining of floor
var g = 350; // gap
var my = 95; // mario y
var up = false; // moving up
window.onclick = jump;
function jump()
{ if (my == 95) up = true; }
draw();
function draw(){
c.fillStyle = 'skyblue';
c.fillRect(0,0,300,150);
var mario = new Image();
mario.src = "http://i66.tinypic.com/2e3tvsj.gif";
c.drawImage(mario,50,my);
if (up) my -= 2
if (my < 50) up = false
if (!up && my < 95) my += 1
for (var x=0+k; x<350+k; x+=25) {
c.fillStyle = 'brown';
c.fillRect(x,125,25,25);
c.strokeRect(x,125,25,25); }
k = k - 1;
if (k == -25) k = 0;
c.fillStyle = 'skyblue';
c.fillRect(g,124,25,26);
g = g - 1;
if (g == -25) g = 350;
requestAnimationFrame(draw);
}
</script>