updated debug function
This commit is contained in:
parent
9aed8171d0
commit
0493aa0c98
@ -53,7 +53,7 @@ io.on('connection', (socket)=>{
|
||||
|
||||
socket.on('username',(username)=>{
|
||||
bPlayers[socket.id].username = username
|
||||
console.log("updated username for: "+bPlayers[socket.id])
|
||||
console.log("updated username for: "+bPlayers[socket.id].username)
|
||||
})
|
||||
|
||||
socket.on('message',(message)=>{
|
||||
|
@ -44,22 +44,26 @@ class Player extends Sprite {
|
||||
ctx.fillText("Click X&Y :"+[this.clickX,this.clickY], this.position.x, this.position.y-110);
|
||||
ctx.fillText("Position: "+[Math.round(this.position.x),Math.round(this.position.y)], this.position.x, this.position.y-98);
|
||||
ctx.fillText("Inc X&Y :"+[this.incrementX.toFixed(2),this.incrementY.toFixed(2)], this.position.x, this.position.y-85);
|
||||
ctx.font = 'bold 18px sans-serif';
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillText(this.message, this.position.x, this.position.y-65);
|
||||
|
||||
ctx.font = 'Normal 16px sans-serif';
|
||||
ctx.textAlign = "center";
|
||||
ctx.fillStyle = 'orange';
|
||||
ctx.fillText("user ID: " + this.userId, this.position.x, this.position.y+35);
|
||||
ctx.fillStyle = 'cyan';
|
||||
ctx.fillText(this.username, this.position.x, this.position.y+15);
|
||||
|
||||
ctx.fill()
|
||||
|
||||
|
||||
}
|
||||
update(){
|
||||
ctx.textAlign = "center";
|
||||
ctx.font = 'bold 18px win98';
|
||||
ctx.fillStyle = 'cyan';
|
||||
ctx.fillText(this.username, this.position.x, this.position.y+15);
|
||||
ctx.font = 'normal 15px sans-serif';
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillText(this.message, this.position.x, this.position.y-65);
|
||||
|
||||
ctx.fill()
|
||||
|
||||
|
||||
// if((Math.sign(incrementX)==1&&fPlayer.x<clickCoordinates[0])||(Math.sign(incrementX)==-1&&fPlayer.x>clickCoordinates[0])){fPlayer.x += incrementX;fPlayer.atPosition=false; socket.emit('clickPositionX',fPlayer.x)}else{fPlayer.atPosition=true}
|
||||
|
@ -86,7 +86,7 @@ socket.on('updatePlayers', (bPlayers) =>{
|
||||
fPlayers[id].clickY = bPlayer.clickY
|
||||
fPlayers[id].message = bPlayer.message
|
||||
fPlayers[id].username = bPlayer.username
|
||||
|
||||
|
||||
//update player position without animation if tab is inactive
|
||||
if (document.hidden) {
|
||||
fPlayers[id].position.x = bPlayer.x
|
||||
@ -179,9 +179,9 @@ socket.emit('clickPosition',clickCoordinates)
|
||||
document.querySelector('#textInput').addEventListener('submit',(event)=>{
|
||||
event.preventDefault() //do not refresh page whenform submited
|
||||
var inputValue = document.querySelector('#input').value
|
||||
if(inputValue.includes("/name")){
|
||||
if(inputValue.includes("/name ")){
|
||||
console.log('namechange')
|
||||
fPlayers[socket.id].username = inputValue.replace("/name","")
|
||||
fPlayers[socket.id].username = inputValue.replace("/name ","")
|
||||
socket.emit('username',fPlayers[socket.id].username)
|
||||
}else{
|
||||
fPlayers[socket.id].message=document.querySelector('#input').value
|
||||
|
Loading…
Reference in New Issue
Block a user