-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsprite1.html
55 lines (45 loc) · 991 Bytes
/
sprite1.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE HTML>
<html lang = "en">
<head>
<title>playing with sprites</title>
<meta charset = "UTF-8" />
<style type = "text/css">
</style>
<script type = "text/javascript"
src = "simpleGame.js"></script>
<script type = "text/javascript">
//<![CDATA[
var canvas;
var context;
var sprite;
function init(){
canvas = document.getElementById("drawing");
context = canvas.getContext("2d");
sprite = new Sprite(canvas, "andyGoofy.gif", 50, 50);
sprite.setPosition(100, 100);
sprite.setSpeed(10);
setInterval(gameUpdate, 100);
}
var angle = 0;
function gameUpdate(){
context.clearRect(0, 0, 400, 400);
angle += 10;
if (angle < 360){
angle = 360;
}
sprite.setImgAngle(angle);
sprite.setMoveAngle(90);
sprite.update();
}
//]]>
</script>
</head>
<body onload = "init()">
<h1>Sprite demo mark 1</h1>
<canvas id = "drawing"
height = "400"
width = "400">
<p>Canvas not supported</p>
</canvas>
</body>
</html>