killer car
This commit is contained in:
parent
5bd50974ea
commit
a4c8e32a26
2 changed files with 15 additions and 2 deletions
|
@ -12,7 +12,7 @@ sound.loadSounds();
|
|||
|
||||
class Player
|
||||
{
|
||||
constructor (id,x,y,name, dir,net)
|
||||
constructor (id,x,y,name, dir)
|
||||
{
|
||||
this.name=name;
|
||||
this.x=x;
|
||||
|
@ -223,6 +223,13 @@ class Car
|
|||
//947,1000
|
||||
}
|
||||
|
||||
collide(x,y)
|
||||
{
|
||||
let cx=this.x-carSize/2;
|
||||
let cy=this.y-carSize/2;
|
||||
return (cx<=x && x<=cx+carSize && cy<=y && y<=cy+carSize);
|
||||
}
|
||||
|
||||
Update()
|
||||
{
|
||||
if(this.tick==0) {
|
||||
|
|
|
@ -140,6 +140,7 @@ function game() {
|
|||
playerId=Net.playerId;
|
||||
player=Net.clientPlayer;
|
||||
players=Net.getPlayersToAdd();
|
||||
players.push(new Player(0,-50,-50,"VOITURE",0,null));
|
||||
Renderer.AddPlayer(player)
|
||||
Renderer.SetPlayerId(player.id)
|
||||
|
||||
|
@ -167,7 +168,12 @@ function game() {
|
|||
Renderer.ReloadAff();
|
||||
cars.forEach((c) => {
|
||||
c.Update();
|
||||
})
|
||||
if(c.collide(player.x,player.y))
|
||||
{
|
||||
Net.died(player.id,0);
|
||||
player.x=-50;
|
||||
}
|
||||
});
|
||||
updateBullets(dt);
|
||||
LB.ReloadAff(players, player);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue