index
This commit is contained in:
parent
c59dd04b06
commit
914fdb9cc5
2 changed files with 16 additions and 11 deletions
19
js/game.js
19
js/game.js
|
@ -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 Net = new Network("ws://129.151.227.50:8080/", Renderer);
|
||||||
//let ClientKeyboard = new Keyboard()
|
//let ClientKeyboard = new Keyboard()
|
||||||
|
|
||||||
|
|
||||||
let playerId; //id of client player
|
|
||||||
let players = [];
|
|
||||||
|
|
||||||
Inp = new Input("canvas");
|
Inp = new Input("canvas");
|
||||||
|
|
||||||
Net.connect(); //connect to server, create a player, and retrieve all players info
|
let playerId;
|
||||||
//ClientKeyboard.init();
|
let players = []
|
||||||
|
|
||||||
|
|
||||||
function game() {
|
function game() {
|
||||||
for (var i = players.length - 1; i >= 0; i--) {
|
for (var i = players.length - 1; i >= 0; i--) {
|
||||||
players[i].update([],[]);
|
players[i].update([],[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log(Inp.calculateAngle(500,500))
|
//console.log(Inp.calculateAngle(500,500))
|
||||||
Renderer.ReloadAff();
|
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
|
|
@ -37,7 +37,7 @@ class Network{
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get getPlayerId(){
|
getPlayerId(){
|
||||||
while(this.playerId==null){
|
while(this.playerId==null){
|
||||||
//waiting for connection
|
//waiting for connection
|
||||||
};
|
};
|
||||||
|
@ -51,19 +51,19 @@ class Network{
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
get getPlayersToAdd(){
|
getPlayersToAdd(){
|
||||||
let tmp = this.playersToAdd;
|
let tmp = this.playersToAdd;
|
||||||
this.playersToAdd = [];
|
this.playersToAdd = [];
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
get getPlayersToRemove(){
|
getPlayersToRemove(){
|
||||||
let tmp = this.playersToRemove;
|
let tmp = this.playersToRemove;
|
||||||
this.playersToRemove = [];
|
this.playersToRemove = [];
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
get getPlayersToUpdate(){
|
getPlayersToUpdate(){
|
||||||
let tmp = this.playersToUpdate;
|
let tmp = this.playersToUpdate;
|
||||||
this.playersToUpdate = [];
|
this.playersToUpdate = [];
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|
Loading…
Reference in a new issue