-
Notifications
You must be signed in to change notification settings - Fork 0
/
shooting - Copy.html
62 lines (45 loc) · 1.16 KB
/
shooting - Copy.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
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset = "utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<center>
<canvas id="canvas" width="1200" height="550"></canvas>
<br>
<textarea id="log"></textarea>
</center>
<script src="utils.js"></script>
<script src="Bars.js"></script>
<script src="target.js"></script>
<script src="gun.js"></script>
<script type="text/javascript">
window.onload = function(){
var canvas = document.getElementById("canvas"),
context = canvas.getContext('2d'),
mouse = utils.captureMouse(canvas),
gun = new Gun(),
target = new Target();
target.x = canvas.width/2;
target.y = canvas.height/2;
(function drawFrame(){
window.requestAnimationFrame(drawFrame,canvas);
context.clearRect(0,0,canvas.width, canvas.height);
gun.x = mouse.x;
gun.y = mouse.y+12;
if(utils.containsPoint(target.getBounds(),mouse.x,mouse.y))
{
log.value = "Hits";
}
else {
log.value = "";
}
target.draw(context);
gun.draw(context);
}());
}
</script>
</body>
</html>