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,13 +229,11 @@ class Car
|
||||||
|
|
||||||
Update(dt)
|
Update(dt)
|
||||||
{
|
{
|
||||||
if(this.tick==0 && (new Date()).getSeconds()%20==this.spawn) {
|
if(this.tick==0 && (new Date()).getSeconds()%60==this.spawn) {
|
||||||
this.tick=1;
|
this.tick=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.tick==0)
|
if(this.tick>0) {
|
||||||
return;
|
|
||||||
|
|
||||||
this.ChangeDirection();
|
this.ChangeDirection();
|
||||||
|
|
||||||
switch (this.dir) {
|
switch (this.dir) {
|
||||||
|
@ -258,6 +256,7 @@ class Car
|
||||||
this.drift = 0;
|
this.drift = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pseudoaleatoire() {
|
pseudoaleatoire() {
|
||||||
return Math.floor(Date.now()/1000)%10
|
return Math.floor(Date.now()/1000)%10
|
||||||
|
|
|
@ -10,7 +10,7 @@ function game() {
|
||||||
}
|
}
|
||||||
|
|
||||||
cars.forEach((c) => {
|
cars.forEach((c) => {
|
||||||
c.Update();
|
c.Update(dt);
|
||||||
if(c.collide(player.x,player.y,player.z))
|
if(c.collide(player.x,player.y,player.z))
|
||||||
{
|
{
|
||||||
net.died(player.id,-1);
|
net.died(player.id,-1);
|
||||||
|
|
|
@ -16,12 +16,17 @@ let PNJS = [new PNJ(500, 100,0),
|
||||||
new PNJ(500, 600,0),
|
new PNJ(500, 600,0),
|
||||||
new PNJ(200, 700,0)];
|
new PNJ(200, 700,0)];
|
||||||
|
|
||||||
let cars = [new Car(0, 0),
|
let cars = [new Car(1, 7),
|
||||||
new Car(1, 7),
|
//new Car(1, 12),
|
||||||
new Car(1, 13),
|
new Car(1, 20),
|
||||||
new Car(1, 14),
|
//new Car(1, 34),
|
||||||
new Car(0, 7),
|
new Car(1, 58),
|
||||||
new Car(0, 15)];
|
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
|
let portals = [new Portal(250,457,0,500,500,0),//O
|
||||||
new Portal(344,758,0,500,500,0), // SO
|
new Portal(344,758,0,500,500,0), // SO
|
||||||
new Portal(1190,211,0,500,500,0),// NE
|
new Portal(1190,211,0,500,500,0),// NE
|
||||||
|
|
|
@ -125,7 +125,7 @@ class Render {
|
||||||
this.RenderPlayer(player,true);
|
this.RenderPlayer(player,true);
|
||||||
|
|
||||||
cars.forEach((car) => {
|
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) => {
|
players.forEach((player) => {
|
||||||
this.RenderPlayer(player,false);
|
this.RenderPlayer(player,false);
|
||||||
|
|
Loading…
Reference in a new issue