This commit is contained in:
Marty Killian 2023-12-12 13:53:41 +01:00
parent 3f811fca5d
commit 5e83426ebd
4 changed files with 14 additions and 12 deletions

View file

@ -213,12 +213,12 @@ class Car
let collide = (cx<=x && x<=cx+carSize && cy<=y && y<=cy+carSize);
if(collide) {
driftSound.play()
this.drift=300;
this.drift=300*dt;
}
return collide;
}
Update()
Update(dt)
{
if(this.tick==0 && (new Date()).getSeconds()%20==this.spawn) {
this.tick=1;
@ -244,7 +244,7 @@ class Car
break;
}
if(this.drift > 0) {
this.drift--
this.drift-=dt;
}
}
@ -310,7 +310,9 @@ class Car
this.dir=4
this.angle=Math.PI/2
} else if(this.y>1000) {
//tp
if(this.drift > 0) {
this.drift--
} //tp
this.x=1247
this.y=-40
this.tick=0;

View file

@ -10,7 +10,7 @@ function game() {
}
cars.forEach((c) => {
c.Update();
c.Update(dt);
if(c.collide(player.x,player.y))
{
net.died(player.id,-1);

View file

@ -15,12 +15,12 @@ let PNJS = [new PNJ(500, 100),
new PNJ(500, 600),
new PNJ(200, 700)];
let cars = [new Car(renderer, 0, 0),
new Car(renderer, 0, 7),
new Car(renderer, 1, 3),
new Car(renderer, 1, 13),
new Car(renderer, 1, 14),
new Car(renderer, 0, 15)];
let cars = [new Car(0, 0),
new Car(0, 7),
new Car(1, 3),
new Car(1, 13),
new Car(1, 14),
new Car(0, 15)];
function updatePlayer(data)
{

View file

@ -119,7 +119,7 @@ class Render {
this.ctx.drawImage(fond, 0, 0, mapWidth, mapHeight);
this.RenderPlayer(player,true);
cars.forEach((car) => {
this.RenderCar(car.x,car.y,car.angle+(car.drift>0?2.1:0));
this.RenderCar(car.x,car.y,car.angle+(car.drift>0?car.drift/200:0));
});
players.forEach((player) => {
this.RenderPlayer(player,false);