add client side terrain without collision
This commit is contained in:
+21
-5
@@ -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()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user