This commit is contained in:
Baptiste 2023-11-29 17:06:30 +01:00
parent c59dd04b06
commit 914fdb9cc5
2 changed files with 16 additions and 11 deletions

View file

@ -2,22 +2,27 @@ Renderer = new Render("canvas", "./assets/map/map7_recadr.png");
let Net = new Network("ws://129.151.227.50:8080/", Renderer);
//let ClientKeyboard = new Keyboard()
let playerId; //id of client player
let players = [];
Inp = new Input("canvas");
Net.connect(); //connect to server, create a player, and retrieve all players info
//ClientKeyboard.init();
let playerId;
let players = []
function game() {
for (var i = players.length - 1; i >= 0; i--) {
players[i].update([],[]);
}
//console.log(Inp.calculateAngle(500,500))
Renderer.ReloadAff();
}
setInterval(game);
function Start() {
playerId = Net.getPlayerId(); //id of client player
//Net.getPlayersToAdd.forEach((Player) => players[Player[id]] = Player)
setInterval(game)
}
Net.onready = Start();
Net.connect(); //connect to server, create a player, and retrieve all players info

View file

@ -37,7 +37,7 @@ class Network{
})
}
get getPlayerId(){
getPlayerId(){
while(this.playerId==null){
//waiting for connection
};
@ -51,19 +51,19 @@ class Network{
}))
}
get getPlayersToAdd(){
getPlayersToAdd(){
let tmp = this.playersToAdd;
this.playersToAdd = [];
return tmp;
}
get getPlayersToRemove(){
getPlayersToRemove(){
let tmp = this.playersToRemove;
this.playersToRemove = [];
return tmp;
}
get getPlayersToUpdate(){
getPlayersToUpdate(){
let tmp = this.playersToUpdate;
this.playersToUpdate = [];
return tmp;