Compare commits
No commits in common. "63b9d1652c473abd7615c22bfc3c7d21cc29c16d" and "914fdb9cc50a8d30371a314d4507c72a357ebf7c" have entirely different histories.
63b9d1652c
...
914fdb9cc5
4 changed files with 10 additions and 47 deletions
|
|
@ -52,6 +52,7 @@ class Player
|
|||
if(this.dir!=0){
|
||||
this.visibleDir = newDirection;
|
||||
}
|
||||
Net.update(this);
|
||||
}
|
||||
|
||||
update(squares,circles)//update position
|
||||
|
|
@ -188,6 +189,6 @@ class Circle
|
|||
|
||||
collide(point)
|
||||
{
|
||||
return ((point.x-this.x)**2+(point.y-this.y)**2<=this.r**2);
|
||||
return ((point.x-this.x)**2+(point.y-this.y)**2<=r**2);
|
||||
}
|
||||
}
|
||||
28
js/game.js
28
js/game.js
|
|
@ -2,40 +2,20 @@ 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 = null; //id of client player
|
||||
let players = [];
|
||||
let player = null;
|
||||
|
||||
Inp = new Input("canvas");
|
||||
|
||||
playerId=Net.playerId;
|
||||
player=Net.clientPlayer;
|
||||
players=Net.getPlayersToAdd();
|
||||
|
||||
let playerId;
|
||||
let players = []
|
||||
|
||||
|
||||
function game() {
|
||||
if(playerId==null)
|
||||
{
|
||||
if (Net.playerId!=null)
|
||||
{
|
||||
playerId=Net.playerId;
|
||||
player=Net.clientPlayer;
|
||||
players=Net.getPlayersToAdd();
|
||||
//Inp.player=player; //pour connecter les input au joueur client
|
||||
console.log("Connected as id ",playerId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = players.length - 1; i >= 0; i--) {
|
||||
players[i].update([],[]);//squares, circles
|
||||
players[i].update([],[]);
|
||||
}
|
||||
|
||||
//console.log(Inp.calculateAngle(500,500))
|
||||
Renderer.ReloadAff();
|
||||
}
|
||||
}
|
||||
|
||||
function Start() {
|
||||
playerId = Net.getPlayerId(); //id of client player
|
||||
|
|
|
|||
|
|
@ -1,17 +1,3 @@
|
|||
/////////////
|
||||
/////////////
|
||||
/////////////
|
||||
// DEAD CLASS !!!
|
||||
// DO NOT USE
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Keyboard{
|
||||
constructor(){
|
||||
this.keysDown = new Set()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ class Network{
|
|||
this.connected = false;
|
||||
|
||||
this.playerId = null;
|
||||
this.clientPlayer=null;
|
||||
this.playersToAdd = [];
|
||||
this.playersToRemove = [];
|
||||
this.playersToUpdate = [];
|
||||
|
|
@ -15,9 +14,6 @@ class Network{
|
|||
case 'connect':
|
||||
this.playerId = data.data.playerId;
|
||||
for (var i = data.data.players.length - 1; i >= 0; i--) {
|
||||
if(data.data.players[i].id==this.playerId)
|
||||
this.clientPlayer=data.data.players[i];
|
||||
else
|
||||
this.playersToAdd.push(new Player(data.data.players[i].id, data.data.players[i].x, data.data.players[i].y, data.data.players[i].name, data.data.players[i].dir))
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue