-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
65 lines (51 loc) · 1.75 KB
/
index.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
56
57
58
59
60
61
62
63
64
65
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<link rel="stylesheet" href="styles.css"/>
</head>
<body>
<script src="jquery.js"></script>
<h1>Test for jQuery</h1>
<script type="text/javascript">
var CANVAS_WIDTH = window.innerWidth*0.8;
var CANVAS_HEIGHT = window.innerHeight*0.8;
var cWidth = CANVAS_WIDTH;
var cHeight = CANVAS_HEIGHT;
var canvasElement = $("<canvas width='" + CANVAS_WIDTH +
"' height='" + CANVAS_HEIGHT + "'></canvas>");
var canvas = canvasElement.get(0).getContext("2d");
canvasElement.appendTo('body');
var textX = 100;
var textY = 100;
var FPS = 60;
function Sprite(x,y,w,h,img_src) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.img = new Image();
this.img.src = img_src;
this.draw = function(){
canvas.drawImage(this.img, this.x,this.y,this.w,this.h);
};
}
var obstacle = new Sprite(10,10,50,50,"http://www.wpclipart.com/smiley/assorted_smiley/assorted_2/fuzzball_smiley.svg");
setInterval(function() {
update();
draw();
}, 1000/FPS);
function update(){
textX += 1;
textY += 1;
}
function draw(){
canvas.clearRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);
canvas.fillStyle = "#000"; // Set color to black
canvas.font = "30px Arial";
canvas.fillText("Sup!", textX, textY);
obstacle.draw();
}
</script>
</body>
</html>