temp save
This commit is contained in:
parent
bf703acd56
commit
b4541b2698
1 changed files with 9 additions and 52 deletions
|
@ -9,54 +9,14 @@ imgCar.src = "./assets/car.png";
|
|||
map.src = "./assets/map_principale.png"
|
||||
map2.src = "./assets/map_secondaire.png";
|
||||
|
||||
|
||||
|
||||
//#######################################
|
||||
class Render {
|
||||
|
||||
constructor(id) {
|
||||
this.canvas = document.getElementById(id);
|
||||
constructor(idCanvas) {
|
||||
this.canvas = document.getElementById(idCanvas);
|
||||
this.ctx = canvas.getContext("2d");
|
||||
this.players = [];
|
||||
this.bullets = [];
|
||||
this.mapsrc=mapsrc;
|
||||
this.map2src=map2src;
|
||||
this.ReloadAff();
|
||||
this.playerid=0;
|
||||
this.map=0
|
||||
}
|
||||
|
||||
SetPlayerId(id) {
|
||||
this.playerid=id
|
||||
}
|
||||
|
||||
AddPlayer(player) {
|
||||
this.players.push(player);
|
||||
}
|
||||
|
||||
addBullet(bullet) {
|
||||
this.bullets.push(bullet);
|
||||
}
|
||||
|
||||
remBullet(bullet) {
|
||||
for(let i=0;i<this.bullets.length;i++) {
|
||||
if(bullet==this.bullets[i]) {
|
||||
this.bullets.splice(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RemPlayer(id) {
|
||||
for(let i=0;i<this.players.length;i++)
|
||||
{
|
||||
if(this.players[i].id==id)
|
||||
{
|
||||
this.players.splice(i,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RenderPlayer(player) {
|
||||
let x=player.x
|
||||
let y=player.y
|
||||
|
@ -108,23 +68,20 @@ class Render {
|
|||
}
|
||||
|
||||
ReloadAff() {
|
||||
/*
|
||||
const fond = new Image();
|
||||
this.players.forEach((p) => {
|
||||
if(p.id==this.playerid) {
|
||||
//console.log(p)
|
||||
if(p.x >= 2000 && p.y >=2000) {
|
||||
this.map=1
|
||||
} else {
|
||||
this.map=0
|
||||
}
|
||||
}
|
||||
})
|
||||
if(player.x >= 2000 && player.y >=2000) {
|
||||
this.map=1;
|
||||
} else {
|
||||
this.map=0;
|
||||
}
|
||||
|
||||
if(this.map==0) {
|
||||
fond.src = this.mapsrc;
|
||||
} else {
|
||||
fond.src = this.map2src;
|
||||
}
|
||||
*/
|
||||
mapWidth = fond.width;
|
||||
mapHeith = fond.height;
|
||||
this.ctx.canvas.width = mapWidth;
|
||||
|
|
Loading…
Reference in a new issue