-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathator.js
135 lines (123 loc) · 2.25 KB
/
ator.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//código do ator
let xAtor = 85;
let yAtor = 360;
let colisao = false;
let meusPontos = 0;
var dificuldade = 3;
function mostraAtor(){
image(imagemDoAtor, xAtor, yAtor, 40, 50)
}
/*
function movimentaAtor(){
if (keyIsDown(UP_ARROW || 87)){
yAtor -= 3;
}
if (keyIsDown(DOWN_ARROW || 83)){
if (podeSeMover()){
yAtor += 3;
}
}
}
function movimentaXAtor(){
if (keyIsDown(LEFT_ARROW || 65)){
xAtor -= 3;
}
if (keyIsDown(RIGHT_ARROW || 68)){
if (podeSeMover()){
xAtor += 3;
}
}
}
*/
function movimentaAtor(){
if (keyIsDown(UP_ARROW)){
yAtor -= 2;
}
else{
if (keyIsDown(DOWN_ARROW) && yAtor < 366){
yAtor += 2;
}
else{
if (keyIsDown(LEFT_ARROW) && xAtor > 0){
xAtor -=2;
}
else{
if (keyIsDown(RIGHT_ARROW) && xAtor < 470){
xAtor +=2;
}
}
}
}
}
function movimentaAtor2(){
if (keyIsDown(87)){
yAtor -= 2;
}
else{
if (keyIsDown(83) && yAtor < 366){
yAtor += 2;
}
else{
if (keyIsDown(65) && xAtor > 0){
xAtor -=2;
}
else{
if (keyIsDown(68) && xAtor < 470){
xAtor +=2;
}
}
}
}
}
function verificaColisao(){
//collideRectCircle(x1, y1, width1, height1, cx, cy, diameter)
for (let i = 0; i < imagemCarros.length; i++){
colisao = collideRectCircle(xCarros[i], yCarros[i], comprimentoCarro, alturaCarro, xAtor, yAtor, 15)
if (colisao){
voltaAtorParaPosicaoInicial();
perdePonto();
somDaColisao.play();
}
}
}
function voltaAtorParaPosicaoInicial(){
yAtor = 360;
xAtor = 85;
}
function incluiPontos(){
textAlign(CENTER);
textSize(25)
fill (color(255, 254, 252))
text (meusPontos, width / 15, 26);
}
function marcaPonto(){
if (yAtor < 15){
meusPontos += 1;
somDoPonto.play();
voltaAtorParaPosicaoInicial();
aumentaDificuldade();
mudaVelocidades();
}
}
function perdePonto(){
if (meusPontos > 0){
meusPontos -=1;
diminuiDificuldade();
mudaVelocidades();
}
}
function aumentaDificuldade(){
if (dificuldade < 8){
dificuldade++;
}
}
function diminuiDificuldade(){
if (dificuldade > 3){
dificuldade -=1;
}
}
/*
function podeSeMover(){
return yAtor < 366;
}
*/