fix (voiture) : au moins c'est synchro (sans dt) et ça render
This commit is contained in:
parent
76d52eeaa7
commit
8fd6b7f7d8
4 changed files with 36 additions and 32 deletions
|
@ -229,33 +229,32 @@ class Car
|
|||
|
||||
Update(dt)
|
||||
{
|
||||
if(this.tick==0 && (new Date()).getSeconds()%20==this.spawn) {
|
||||
this.tick=1;
|
||||
if(this.tick==0 && (new Date()).getSeconds()%60==this.spawn) {
|
||||
this.tick=1;
|
||||
}
|
||||
|
||||
if(this.tick==0)
|
||||
return;
|
||||
|
||||
this.ChangeDirection();
|
||||
if(this.tick>0) {
|
||||
this.ChangeDirection();
|
||||
|
||||
switch (this.dir) {
|
||||
case 1:
|
||||
this.x=this.x+this.tick
|
||||
break;
|
||||
case 2:
|
||||
this.y=this.y-this.tick
|
||||
break;
|
||||
case 3:
|
||||
this.x=this.x-this.tick
|
||||
break;
|
||||
case 4:
|
||||
this.y=this.y+this.tick
|
||||
break;
|
||||
}
|
||||
if(this.drift > 0) {
|
||||
this.drift-=dt;
|
||||
}else{
|
||||
this.drift = 0;
|
||||
switch (this.dir) {
|
||||
case 1:
|
||||
this.x=this.x+this.tick
|
||||
break;
|
||||
case 2:
|
||||
this.y=this.y-this.tick
|
||||
break;
|
||||
case 3:
|
||||
this.x=this.x-this.tick
|
||||
break;
|
||||
case 4:
|
||||
this.y=this.y+this.tick
|
||||
break;
|
||||
}
|
||||
if(this.drift > 0) {
|
||||
this.drift-=dt;
|
||||
}else{
|
||||
this.drift = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ function game() {
|
|||
}
|
||||
|
||||
cars.forEach((c) => {
|
||||
c.Update();
|
||||
c.Update(dt);
|
||||
if(c.collide(player.x,player.y,player.z))
|
||||
{
|
||||
net.died(player.id,-1);
|
||||
|
|
|
@ -16,12 +16,17 @@ let PNJS = [new PNJ(500, 100,0),
|
|||
new PNJ(500, 600,0),
|
||||
new PNJ(200, 700,0)];
|
||||
|
||||
let cars = [new Car(0, 0),
|
||||
new Car(1, 7),
|
||||
new Car(1, 13),
|
||||
new Car(1, 14),
|
||||
new Car(0, 7),
|
||||
new Car(0, 15)];
|
||||
let cars = [new Car(1, 7),
|
||||
//new Car(1, 12),
|
||||
new Car(1, 20),
|
||||
//new Car(1, 34),
|
||||
new Car(1, 58),
|
||||
new Car(0, 0),
|
||||
//new Car(0, 7),
|
||||
new Car(0, 18),
|
||||
//new Car(0, 26),
|
||||
new Car(0, 45),
|
||||
new Car(0, 52)];
|
||||
let portals = [new Portal(250,457,0,500,500,0),//O
|
||||
new Portal(344,758,0,500,500,0), // SO
|
||||
new Portal(1190,211,0,500,500,0),// NE
|
||||
|
|
|
@ -125,7 +125,7 @@ class Render {
|
|||
this.RenderPlayer(player,true);
|
||||
|
||||
cars.forEach((car) => {
|
||||
this.RenderCar(car.x,car.y,car.angle+(car.drift>0?car.drift/150:0));
|
||||
this.RenderCar(car.x,car.y,0,car.angle/*+(car.drift>0?car.drift/150:0)*/);
|
||||
});
|
||||
players.forEach((player) => {
|
||||
this.RenderPlayer(player,false);
|
||||
|
|
Loading…
Reference in a new issue