-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
85 lines (81 loc) · 2.24 KB
/
Copy pathtest.html
File metadata and controls
85 lines (81 loc) · 2.24 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head>
<style>
canvas
{
border:1px solid black;
}
</style>
<script>
let ctx, canvas, screen, atack_x, atack_y;
function init(a, b)
{
screen = document.getElementById('screen');
ctx = screen.getContext('2d');
sound();
}
function cannon_direction(event)
{
atack_x = event.clientX;
atack_y = event.clientY;
qq( atack_x, atack_y);
//alert('jopa');
//alert(atack_x + ' ' + atack_y);
//alert(unit[0].object_x + ' ' + unit[0].object_y)
//alert(a.object_x);
//alert(unit[0].object_x);
}
function qq(a, b)
{
ctx.save();
ctx.beginPath();
//ctx.rotate(70 * Math.PI/180);
/*ctx.moveTo(300,200);
ctx.lineTo(100,200);
ctx.stroke();*/
/*ctx.translate(0, 0);
ctx.translate(300, 200);
ctx.rotate(Math.abs(a - b)* Math.PI/180);
ctx.fillRect(0,0,230,13)
ctx.restore();*/
ctx.moveTo(300,200);
ctx.lineTo(a,b);
ctx.stroke();
ctx.closePath();
ctx.restore();
}
function sound()
{
let a = new Audio();
a.src = 'a.m4a';
if (!a.autoplay)a.play();
}
function muzplay()
{
let muz = new Audio();
muz.src = 'a.m4a';
let button = document.getElementById("play");
if (muz.paused) {
muz.play();
button.textContent = "||";
} else {
muz.pause();
button.textContent = ">";
}
}
</script>
<style>
body{ margin: 0;}
canvas
{
background-color: rgb(255, 200, 241);
border: 1px solid black;
}
</style>
</head>
<body >
<canvas width='600' height='400' id='screen' onClick = "cannon_direction(event)"></canvas>
<button onClick='sound()' id = "play">sound</button>
</body>
</html>