xxxxxxxxxx
56
//Carros
let comprimentoCarro = 54;
let alturaCarro = 33;
let xCarros = [650, 650, 650];
let xCarrosI = [-50, -50, -50];
let yCarros = [42, 97, 151];
let yCarrosI = [214, 263, 319];
let velocidadeCarros = [2, 2.5, 3];
let velocidadeCarrosI = [3, 2.5, 2];
function mostraCarro(){
for (let i = 0; i < imagensDosCarros.length; i++){
image(imagensDosCarros[i], xCarros[i], yCarros[i], comprimentoCarro, alturaCarro);
}
}
function movimentoCarro(){
for (let i = 0; i < imagensDosCarros.length; i++){
xCarros[i] = (xCarros[i] - velocidadeCarros[i]) - adicional;
}
}
function voltaCarroAoInicio(){
for (let i = 0; i < imagensDosCarros.length; i++){
if (passouTodaTela(xCarros[i])){
xCarros[i] = 650;
}
}
}
function passouTodaTela(qualquerCoisa){
return qualquerCoisa < -50;
}
function mostraCarroI(){
for (let i = 0; i < imagensDosCarrosI.length; i++){
image(imagensDosCarrosI[i], xCarrosI[i], yCarrosI[i], comprimentoCarro, alturaCarro);
}
}
function movimentoCarroI(){
for (let i = 0; i < imagensDosCarrosI.length; i++){
xCarrosI[i] = (xCarrosI[i] + velocidadeCarrosI[i]) + adicional;
}
}
function voltaCarroAoInicioI(){
for (let i = 0; i < imagensDosCarrosI.length; i++){
if (passouTodaTelaI(xCarrosI[i])){
xCarrosI[i] = -50;
}
}
}
function passouTodaTelaI(qualquerCoisa){
return qualquerCoisa > 650;
}