temp save

This commit is contained in:
Atsuyo-INSA 2023-12-08 17:04:16 +01:00
parent bf703acd56
commit b4541b2698

View file

@ -9,54 +9,14 @@ imgCar.src = "./assets/car.png";
map.src = "./assets/map_principale.png" map.src = "./assets/map_principale.png"
map2.src = "./assets/map_secondaire.png"; map2.src = "./assets/map_secondaire.png";
//#######################################
class Render { class Render {
constructor(idCanvas) {
constructor(id) { this.canvas = document.getElementById(idCanvas);
this.canvas = document.getElementById(id);
this.ctx = canvas.getContext("2d"); this.ctx = canvas.getContext("2d");
this.players = [];
this.bullets = [];
this.mapsrc=mapsrc;
this.map2src=map2src;
this.ReloadAff(); this.ReloadAff();
this.playerid=0;
this.map=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) { RenderPlayer(player) {
let x=player.x let x=player.x
let y=player.y let y=player.y
@ -108,23 +68,20 @@ class Render {
} }
ReloadAff() { ReloadAff() {
/*
const fond = new Image(); const fond = new Image();
this.players.forEach((p) => { if(player.x >= 2000 && player.y >=2000) {
if(p.id==this.playerid) { this.map=1;
//console.log(p)
if(p.x >= 2000 && p.y >=2000) {
this.map=1
} else { } else {
this.map=0 this.map=0;
} }
}
})
if(this.map==0) { if(this.map==0) {
fond.src = this.mapsrc; fond.src = this.mapsrc;
} else { } else {
fond.src = this.map2src; fond.src = this.map2src;
} }
*/
mapWidth = fond.width; mapWidth = fond.width;
mapHeith = fond.height; mapHeith = fond.height;
this.ctx.canvas.width = mapWidth; this.ctx.canvas.width = mapWidth;