-
Notifications
You must be signed in to change notification settings - Fork 0
/
actor.js
61 lines (50 loc) · 1.08 KB
/
actor.js
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
//cógido do ator
let xAtor = 90;
let yAtor = 366;
let colisao = false;
let meusPontos = 0;
function mostraAtor() {
image(imagemDoAtor, xAtor, yAtor, 30,30);
}
function movimentaAtor() {
if (keyIsDown(UP_ARROW)) {
yAtor -= 3;
}
}
if (keyIsDown(DOWN_ARROW)) {
if (podeSeMover()) {
Ator += 3;
}
}
function podeSeMover() {
return yAtor < 366;
}
function verificaColisao() {
//collideRectCircle(x1, y1, width1, height1, cx, cy, diameter)
for (let i = 0; i < imagemDoCarros.length; i = i +1){
colisao = collideRectCircle(xCarros[i], yCarros[i], comprimentoCarro, alturaCarro, xAtor, yAtor, 15)
if (colisao){
back();
somDaColisao.play();
if (meusPontos > 0){
meusPontos -= 1;
}
}
}
}
function back() {
yAtor = 366;
}
function incluiPontos() {
textAlign(CENTER);
textSize(25);
fill(color(255, 250, 30))
text(meusPontos, width /5, 25);
}
function marcaPonto() {
if (yAtor < 15) {
meusPontos += 1;
back();
somDoPonto.play();
}
}