Update server/static/map.js
This commit is contained in:
@@ -20,6 +20,11 @@ export class MapView {
|
|||||||
this.otherSprites = new Map(); // socket.id -> { img,label }
|
this.otherSprites = new Map(); // socket.id -> { img,label }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPlayerPosition() {
|
||||||
|
if (!this.player) return { x: 0, y: 0 };
|
||||||
|
return { x: this.player.x, Y: this.player.y};
|
||||||
|
}
|
||||||
|
|
||||||
create(me, world, nodes) {
|
create(me, world, nodes) {
|
||||||
const W = world?.width || this.config.width;
|
const W = world?.width || this.config.width;
|
||||||
const H = world?.height || this.config.height;
|
const H = world?.height || this.config.height;
|
||||||
@@ -52,6 +57,7 @@ export class MapView {
|
|||||||
}
|
}
|
||||||
g.setDepth(-100); // stay behind everything
|
g.setDepth(-100); // stay behind everything
|
||||||
|
|
||||||
|
|
||||||
// Player sprite
|
// Player sprite
|
||||||
const startPos = this.snapToTile(me.x, me.y);
|
const startPos = this.snapToTile(me.x, me.y);
|
||||||
this.player = this.scene.add.image(startPos.x, startPos.y, 'player').setDepth(10);
|
this.player = this.scene.add.image(startPos.x, startPos.y, 'player').setDepth(10);
|
||||||
|
|||||||
Reference in New Issue
Block a user