-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.10 - Tiro ao Alvo.html
53 lines (45 loc) · 1.62 KB
/
3.10 - Tiro ao Alvo.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
<canvas width="600" height="400"></canvas>
<body>
<script src="Ferramentas de desenho.js"></script>
<script>
// Seletor de tela
var tela = document.querySelector('canvas');
var desenho = tela.getContext('2d');
corLinha('black');
contornoRet(0, 0, 600, 400);
var r = 10;
function Circulo(xc,yc,r,fundo,textoF,linha,textoL)
{
var tela = document.querySelector('canvas');
var desenho = tela.getContext('2d');
inicio();
arco(xc,yc,r, 0, 2*3.14);
if (textoF == true && textoL == false) {
cor(fundo);
pintar();
}
if (textoF == false && textoL == true) {
corLinha(linha);
contorno();
}
if (textoF == true && textoL == true) {
cor(fundo);
pintar();
corLinha(linha);
contorno();
}
}
Circulo(300, 200, r+20, 'red', true, 'black', false) // maior
Circulo(300, 200, r+10, 'white', true, 'black', false)
Circulo(300, 200, r, 'red', true, 'black', false) // menor
function atirar(evento) {
var x = evento.pageX-tela.offsetLeft;
var y = evento.pageY-tela.offsetTop;
if (x > 300-r && x < 300+r && y > 200-r && y < 200+r)
{ alert('Acertou no Alvo') }
else
{ alert("ERRROOOUUU!!!") }
}
tela.onclick=atirar
</script>
</body>