add lane scenario with HP

This commit is contained in:
2025-01-11 21:40:57 +09:00
parent 462dfe7b9a
commit 957b09b878
4 changed files with 78 additions and 14 deletions
+55 -13
View File
@@ -3,6 +3,8 @@ import { WebSocketExpress } from 'websocket-express'
import Game from './game.js'
import Entity from './entity.js'
import Terrain from './terrain.js'
import SATX from './satx.js'
import { Vector2 } from 'three'
const app = new WebSocketExpress()
const port = 1280
@@ -42,29 +44,23 @@ app.ws('/ws', async (req, res) => {
})
})
app.listen(port, () => {
console.log(`Server started! Visit http://localhost:${port}`)
function testScenario() {
const entity1 = new Entity()
entity1.id = '1'
entity1.teleport(200, 500)
entity1.radius = 50
entity1.maxHealth = 100
entity1.health = 80
game.spawn_entity(entity1)
const entity2 = new Entity()
entity2.id = '2'
entity2.teleport(110, 110)
entity2.radius = 50
entity2.maxHealth = 50
entity2.health = 50
game.spawn_entity(entity2)
// const triangle = new Terrain([
// { x: 400, y: 200 },
// { x: 400, y: 600 },
// { x: 600, y: 300 },
// ])
// triangle.id = 'triangle'
// game.add_terrain(triangle)
const horseshoe = new Terrain([
{ x: 400, y: 200 },
{ x: 600, y: 200 },
@@ -119,9 +115,55 @@ app.listen(port, () => {
])
pole.id = 'pole'
game.add_terrain(pole)
}
// entity1.moveAction(750, 950)
// setTimeout(() => entity1.moveAction(100, 400), 10)
function laneScenario() {
const entity1 = new Entity()
entity1.id = '1'
entity1.teleport(200, 200)
entity1.radius = 50
entity1.maxHealth = 100
entity1.health = 100
game.spawn_entity(entity1)
const entity2 = new Entity()
entity2.id = '2'
entity2.teleport(1800, 1800)
entity2.radius = 50
entity2.maxHealth = 100
entity2.health = 100
game.spawn_entity(entity2)
const midWallStart = new Vector2(400, 400)
const midWallEnd = new Vector2(1600, 1600)
const midWallMiddle = new Vector2(800, 1200)
const midWallThickness = midWallEnd.clone().sub(midWallStart).rotateAround(new Vector2(), -Math.PI / 2).normalize().multiplyScalar(50)
const midWallPoints = [
midWallStart,
midWallMiddle,
midWallEnd,
midWallEnd.clone().add(midWallThickness),
midWallMiddle.clone().add(midWallThickness),
midWallStart.clone().add(midWallThickness),
]
const midNorthWallOffset = new Vector2(-200, 200)
const midNorthWallPoints = midWallPoints.map((p) => p.clone().add(midNorthWallOffset))
const midNorthWall = new Terrain(midNorthWallPoints)
midNorthWall.id = 'midNorthWall'
game.add_terrain(midNorthWall)
const midSouthWallOffset = new Vector2(200, -200)
const midSouthWallPoints = midWallPoints.map((p) => p.clone().add(midSouthWallOffset))
const midSouthWall = new Terrain(midSouthWallPoints)
midSouthWall.id = 'midSouthWall'
game.add_terrain(midSouthWall)
}
app.listen(port, () => {
console.log(`Server started! Visit http://localhost:${port}`)
laneScenario()
game.start()
})