add client side terrain without collision

This commit is contained in:
2024-12-23 11:57:36 +09:00
parent 604368b52c
commit ba0d8f606a
6 changed files with 107 additions and 9 deletions
+21 -5
View File
@@ -2,6 +2,7 @@ import express from 'express'
import { WebSocketExpress } from 'websocket-express'
import Game from './game.js'
import Entity from './entity.js'
import Terrain from './terrain.js'
const app = new WebSocketExpress()
const port = 1280
@@ -39,11 +40,11 @@ app.ws('/ws', async (req, res) => {
app.listen(port, () => {
console.log(`Server started! Visit http://localhost:${port}`)
const entity = new Entity()
entity.id = '1'
entity.teleport(100, 100)
entity.radius = 35
game.spawn_entity(entity)
const entity1 = new Entity()
entity1.id = '1'
entity1.teleport(100, 100)
entity1.radius = 35
game.spawn_entity(entity1)
const entity2 = new Entity()
entity2.id = '2'
@@ -51,5 +52,20 @@ app.listen(port, () => {
entity2.radius = 35
game.spawn_entity(entity2)
const vertices = [
{ x: 0, y: 0 },
{ x: 20, y: 0 },
{ x: 20, y: 20 },
{ x: 10, y: 20 },
{ x: 10, y: 5 },
{ x: 5, y: 5 },
{ x: 5, y: 20 },
{ x: 0, y: 20 },
]
const terrain1 = new Terrain(vertices)
terrain1.id = 'a'
game.add_terrain(terrain1)
game.start()
})