-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathator.js
More file actions
71 lines (60 loc) · 1.14 KB
/
Copy pathator.js
File metadata and controls
71 lines (60 loc) · 1.14 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
//Movimentos Ator
let xAtor1 = 100;
let yAtor1 = 366;
let colisao = false;
let meusPontos = 0;
//Funções de Movimento ator
function mostraAtor1(){
image(imgAtor1, xAtor1, yAtor1, 30, 30);
}
function movimentaAtor1(){
if(keyIsDown(UP_ARROW)){
yAtor1 -= 3;
}
if(keyIsDown(DOWN_ARROW)){
if(podeSeMover()){
yAtor1 += 3;
}
}
if(keyIsDown(LEFT_ARROW)){
xAtor1 -= 3;
}
if(keyIsDown(RIGHT_ARROW)){
xAtor1 += 3;
}
}
function verificaColisao(){
for (let i = 0; i < imgCarros.length; i++){
colisao = collideRectCircle(xCarros[i], yCarros[i], larguraCarro, alturaCarro, xAtor1, yAtor1, 15)
if (colisao){
colidiu();
if (pontosMaiorQueZero()){
meusPontos -= 1;
}
somColisao.play();
}
}
}
function colidiu(){
yAtor1 = 366;
xAtor1 = 100;
}
function incluiPontos(){
textAlign(CENTER);
textSize(25);
fill(color(255, 240, 60));
text(meusPontos, width / 5, 27);
}
function marcaPonto(){
if (yAtor1 < 15){
meusPontos += 1;
colidiu();
somPonto.play();
}
}
function pontosMaiorQueZero(){
return meusPontos > 0;
}
function podeSeMover(){
return yAtor1 < 366;
}