improve position fixing

This commit is contained in:
2025-01-11 18:17:44 +09:00
parent f1c191f61f
commit 4aba510ec0
8 changed files with 117 additions and 34 deletions
+10 -7
View File
@@ -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()