car fix
This commit is contained in:
parent
3f811fca5d
commit
5e83426ebd
4 changed files with 14 additions and 12 deletions
|
@ -213,12 +213,12 @@ class Car
|
||||||
let collide = (cx<=x && x<=cx+carSize && cy<=y && y<=cy+carSize);
|
let collide = (cx<=x && x<=cx+carSize && cy<=y && y<=cy+carSize);
|
||||||
if(collide) {
|
if(collide) {
|
||||||
driftSound.play()
|
driftSound.play()
|
||||||
this.drift=300;
|
this.drift=300*dt;
|
||||||
}
|
}
|
||||||
return collide;
|
return collide;
|
||||||
}
|
}
|
||||||
|
|
||||||
Update()
|
Update(dt)
|
||||||
{
|
{
|
||||||
if(this.tick==0 && (new Date()).getSeconds()%20==this.spawn) {
|
if(this.tick==0 && (new Date()).getSeconds()%20==this.spawn) {
|
||||||
this.tick=1;
|
this.tick=1;
|
||||||
|
@ -244,7 +244,7 @@ class Car
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(this.drift > 0) {
|
if(this.drift > 0) {
|
||||||
this.drift--
|
this.drift-=dt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +310,9 @@ class Car
|
||||||
this.dir=4
|
this.dir=4
|
||||||
this.angle=Math.PI/2
|
this.angle=Math.PI/2
|
||||||
} else if(this.y>1000) {
|
} else if(this.y>1000) {
|
||||||
//tp
|
if(this.drift > 0) {
|
||||||
|
this.drift--
|
||||||
|
} //tp
|
||||||
this.x=1247
|
this.x=1247
|
||||||
this.y=-40
|
this.y=-40
|
||||||
this.tick=0;
|
this.tick=0;
|
||||||
|
|
|
@ -10,7 +10,7 @@ function game() {
|
||||||
}
|
}
|
||||||
|
|
||||||
cars.forEach((c) => {
|
cars.forEach((c) => {
|
||||||
c.Update();
|
c.Update(dt);
|
||||||
if(c.collide(player.x,player.y))
|
if(c.collide(player.x,player.y))
|
||||||
{
|
{
|
||||||
net.died(player.id,-1);
|
net.died(player.id,-1);
|
||||||
|
|
|
@ -15,12 +15,12 @@ let PNJS = [new PNJ(500, 100),
|
||||||
new PNJ(500, 600),
|
new PNJ(500, 600),
|
||||||
new PNJ(200, 700)];
|
new PNJ(200, 700)];
|
||||||
|
|
||||||
let cars = [new Car(renderer, 0, 0),
|
let cars = [new Car(0, 0),
|
||||||
new Car(renderer, 0, 7),
|
new Car(0, 7),
|
||||||
new Car(renderer, 1, 3),
|
new Car(1, 3),
|
||||||
new Car(renderer, 1, 13),
|
new Car(1, 13),
|
||||||
new Car(renderer, 1, 14),
|
new Car(1, 14),
|
||||||
new Car(renderer, 0, 15)];
|
new Car(0, 15)];
|
||||||
|
|
||||||
function updatePlayer(data)
|
function updatePlayer(data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,7 +119,7 @@ class Render {
|
||||||
this.ctx.drawImage(fond, 0, 0, mapWidth, mapHeight);
|
this.ctx.drawImage(fond, 0, 0, mapWidth, mapHeight);
|
||||||
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?2.1:0));
|
this.RenderCar(car.x,car.y,car.angle+(car.drift>0?car.drift/200:0));
|
||||||
});
|
});
|
||||||
players.forEach((player) => {
|
players.forEach((player) => {
|
||||||
this.RenderPlayer(player,false);
|
this.RenderPlayer(player,false);
|
||||||
|
|
Loading…
Reference in a new issue