improve position fixing
This commit is contained in:
+10
-7
@@ -25,6 +25,10 @@ app.ws('/ws', async (req, res) => {
|
||||
websocket.on('message', (rawData) => {
|
||||
const message = JSON.parse(rawData)
|
||||
const entity = message.id != null ? game.entities.find((e) => e.id == message.id) : null
|
||||
if (entity == null) {
|
||||
console.log({ error: { reason: 'Invalid ID', message } })
|
||||
return
|
||||
}
|
||||
console.log(message)
|
||||
|
||||
if (message.action == 'teleport') {
|
||||
@@ -46,11 +50,11 @@ app.listen(port, () => {
|
||||
entity1.radius = 50
|
||||
game.spawn_entity(entity1)
|
||||
|
||||
const entity2 = new Entity()
|
||||
entity2.id = '2'
|
||||
entity2.teleport(110, 110)
|
||||
entity2.radius = 50
|
||||
game.spawn_entity(entity2)
|
||||
// const entity2 = new Entity()
|
||||
// entity2.id = '2'
|
||||
// entity2.teleport(110, 110)
|
||||
// entity2.radius = 50
|
||||
// game.spawn_entity(entity2)
|
||||
|
||||
// const triangle = new Terrain([
|
||||
// { x: 400, y: 200 },
|
||||
@@ -115,8 +119,7 @@ app.listen(port, () => {
|
||||
pole.id = 'pole'
|
||||
game.add_terrain(pole)
|
||||
|
||||
// entity1.moveAction(1000, 500)
|
||||
|
||||
// entity1.moveAction(750, 950)
|
||||
// setTimeout(() => entity1.moveAction(100, 400), 10)
|
||||
|
||||
game.start()
|
||||
|
||||
Reference in New Issue
Block a user