le serveur est down...
This commit is contained in:
parent
f0817769a4
commit
8e79098a63
6 changed files with 27 additions and 25 deletions
|
@ -3,7 +3,7 @@ const carSize = 40.;
|
|||
const playerSpeed=.2;
|
||||
const bulletSpeed=playerSpeed*2;
|
||||
const halfSqrtTwo=0.70710678118;
|
||||
|
||||
const defaulthealth=10;
|
||||
|
||||
class Player
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ class Player
|
|||
//7=West
|
||||
//8=North-West
|
||||
this.ammo=10;
|
||||
this.health=10;
|
||||
this.health=defaulthealth;
|
||||
this.kill=0;
|
||||
this.death=0;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Player
|
|||
{
|
||||
this.death++;
|
||||
net.died(this.id,killerId);
|
||||
this.health=10;
|
||||
this.health=defaulthealth;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class Bullet
|
|||
{
|
||||
constructor (x,y,dx,dy,id)
|
||||
{
|
||||
sound.shoot();
|
||||
bulletSound.play();
|
||||
this.x=x;
|
||||
this.y=y;
|
||||
this.dx=dx;
|
||||
|
@ -123,9 +123,9 @@ class Bullet
|
|||
if(this.deleted)
|
||||
return;
|
||||
|
||||
if(player!=null && player.id!=this.parentId && Math.sqrt((player.x-this.x)**2+(player.y-this.y)**2)<playerSize/2)
|
||||
if(player!=null && player.id!=this.shooterId && Math.sqrt((player.x-this.x)**2+(player.y-this.y)**2)<playerSize/2)
|
||||
{
|
||||
player.takeDamage(1,this.parentId);
|
||||
player.takeDamage(1,this.shooterId);
|
||||
this.deleted=true;
|
||||
return;
|
||||
}
|
||||
|
@ -238,10 +238,10 @@ class Car
|
|||
break;
|
||||
}
|
||||
if(this.drift > 0) {
|
||||
this.Renderer.RenderCar(this.x,this.y, this.angle+2.1)
|
||||
renderer.RenderCar(this.x,this.y, this.angle+2.1)
|
||||
this.drift--
|
||||
} else {
|
||||
this.Renderer.RenderCar(this.x,this.y, this.angle)
|
||||
renderer.RenderCar(this.x,this.y, this.angle)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ function game() {
|
|||
for (let i = 0;i<players.length; i++) {
|
||||
players[i].update(squares, circles, dt);
|
||||
}
|
||||
Renderer.ReloadAff();
|
||||
renderer.ReloadAff();
|
||||
cars.forEach((c) => {
|
||||
c.Update();
|
||||
if(c.collide(player.x,player.y))
|
||||
|
|
|
@ -15,7 +15,7 @@ let renderer = new Render("canvas");
|
|||
let LB = new LeaderBoard("canvas");
|
||||
let bulletSound = new Sound("./assets/sounds/shoot.mp3");
|
||||
let driftSound = new Sound("./assets/sounds/drift.mp3");
|
||||
let net = new Network("ws://129.151.227.50:8080?name="+CookiePseudo());
|
||||
let net = new Network("wss://ws.gta6.insat.fr:8080?name="+CookiePseudo());
|
||||
let inp = new Input("canvas");
|
||||
let date = new Date();
|
||||
let bullets = [];
|
||||
|
|
|
@ -23,10 +23,8 @@ class Input {
|
|||
|
||||
let norm = Math.sqrt(dx*dx+dy*dy);
|
||||
let b = new Bullet(player.x,player.y,dx/norm,dy/norm,player.id);
|
||||
|
||||
bullets.push(b);
|
||||
renderer.addBullet(b);
|
||||
network.newBullet(b.x,b.y,b.dx,b.dy,b.parentId);
|
||||
net.newBullet(b.x,b.y,b.dx,b.dy,b.parentId);
|
||||
});
|
||||
|
||||
window.addEventListener("keydown", (e)=>{
|
||||
|
@ -41,7 +39,7 @@ class Input {
|
|||
}
|
||||
|
||||
updateDir(){
|
||||
if(this.player==null)
|
||||
if(player==null)
|
||||
return;
|
||||
let oldDir=this.dir;
|
||||
this.dir=0;
|
||||
|
@ -74,8 +72,8 @@ class Input {
|
|||
}
|
||||
if(oldDir!=this.dir)
|
||||
{
|
||||
this.player.changeDirection(this.dir);
|
||||
this.network.update(this.player);
|
||||
player.changeDirection(this.dir);
|
||||
net.update(this.player);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ const map2 = new Image();
|
|||
imgPlayer.src = "./assets/body.png";
|
||||
imgBullet.src = "./assets/bullet.png";
|
||||
imgCar.src = "./assets/car.png";
|
||||
map.src = "./assets/map_principale.png"
|
||||
map2.src = "./assets/map_secondaire.png";
|
||||
map.src = "./assets/map/map_principale.png"
|
||||
map2.src = "./assets/map/map_secondaire.png";
|
||||
|
||||
class Render {
|
||||
constructor(idCanvas) {
|
||||
|
@ -74,15 +74,19 @@ class Render {
|
|||
this.map=0;
|
||||
}
|
||||
|
||||
let fond = map;
|
||||
/*
|
||||
if(this.map==0) {
|
||||
let fond = map;
|
||||
} else {
|
||||
let fond = map2;
|
||||
}
|
||||
|
||||
this.ctx.canvas.width = fond.width;
|
||||
this.ctx.canvas.height = fond.height;
|
||||
this.ctx.drawImage(fond, 0, 0, mapWidth, mapHeith);
|
||||
*/
|
||||
let mapWidth = fond.width;
|
||||
let mapHeight = fond.height;
|
||||
this.ctx.canvas.width = mapWidth;
|
||||
this.ctx.canvas.height = mapHeight;
|
||||
this.ctx.drawImage(fond, 0, 0, mapWidth, mapHeight);
|
||||
this.RenderPlayer(player,true);
|
||||
players.forEach((player) => {
|
||||
this.RenderPlayer(player,false);
|
||||
|
|
|
@ -5,8 +5,8 @@ class Sound{
|
|||
}
|
||||
|
||||
play(){
|
||||
this.shootSound.pause()
|
||||
this.shootSound.currentTime=0;
|
||||
this.shootSound.play()
|
||||
this.sound.pause()
|
||||
this.sound.currentTime=0;
|
||||
this.sound.play()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue