-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcarro.js
More file actions
30 lines (26 loc) · 735 Bytes
/
Copy pathcarro.js
File metadata and controls
30 lines (26 loc) · 735 Bytes
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
//codigo do carro
let xCarros = [600 , 600 ,600 ,600 , 600 ,600];
let yCarros = [40 , 96, 150 , 210 , 270 , 318];
let velocidadeCarros = [2 , 2.5 , 3.2 , 5 , 3.3 , 2.3];
let comprimentoCarro = 50;
let alturaCarro = 40;
function mostraCarro(){
for(let i = 0; i < imagemCarros.length; i ++){
image(imagemCarros[i] , xCarros[i], yCarros[i] , comprimentoCarro , alturaCarro);
}
}
function movimentaCarro(){
for (let i = 0;i < imagemCarros.length; i ++){
xCarros[i] -= velocidadeCarros[i];
}
}
function voltaPosicaoInicialDoCarro(){
for (let i = 0;i < imagemCarros.length;i ++){
if (passouTodaATela(xCarros[i])){
xCarros[i] = 600;
}
}
}
function passouTodaATela(xCarros){
return xCarros < -50;
}