-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.html
50 lines (44 loc) · 983 Bytes
/
test.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
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<style type="text/css">
canvas {
position: absolute;
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
<canvas id="main"></canvas>
<script type="text/javascript" src="explosion.js"></script>
<script type="text/javascript">
var canvas = document.getElementById("main");
var context= canvas.getContext("2d");
var angle = 0;
canvas.width = 400;
canvas.height = 300;
x_pos = 200;
y_pos = 150;
window.addEventListener("mousemove", function (e) {
var x_dist = x_pos - e.clientX;
var y_dist = y_pos - e.clientY;
angle = (Math.atan2(y_dist, x_dist)*180/Math.PI);
console.log(angle);
}, false);
window.onload = loop;
function loop() {
context.fillStyle = "black"
context.fillRect(0, 0, canvas.width, canvas.height);
context.fill();
var t = new thrust(x_pos, y_pos, angle);
t.update();
window.requestAnimationFrame(loop, 1000/60);
}
</script>
</body>
</html>