summaryrefslogtreecommitdiff
path: root/server/src/main.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-26 17:55:27 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-08-26 17:55:27 -0600
commit6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8 (patch)
treee60767dc5295edf379cf421e20171dc418e548b7 /server/src/main.ts
parent594921352c8d82fe5f1a6201a4d5f9fbd9b719fc (diff)
downloadjumpstorm-6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8.tar.gz
jumpstorm-6ce6946a4401d2ee6fa5cb747fab7d4c658a63c8.zip
add entity updates over network!
Diffstat (limited to 'server/src/main.ts')
-rw-r--r--server/src/main.ts41
1 files changed, 34 insertions, 7 deletions
diff --git a/server/src/main.ts b/server/src/main.ts
index 965e0d7..0e47491 100644
--- a/server/src/main.ts
+++ b/server/src/main.ts
@@ -2,28 +2,55 @@ import { Grid } from '@engine/structures';
import {
ServerMessageProcessor,
ServerSocketMessagePublisher,
- ServerSocketMessageReceiver
+ ServerSocketMessageReceiver,
+ MemorySessionManager,
+ SessionInputSystem
} from './network';
import { Collision, NetworkUpdate, Physics, WallBounds } from '@engine/systems';
import { Game } from '@engine/Game';
import { Constants } from './constants';
import { GameServer } from './server';
+import { Floor } from '@engine/entities';
+import { BoundingBox } from '@engine/components';
+import { Miscellaneous } from '@engine/config';
+
+const game = new Game();
+
+const sessionManager = new MemorySessionManager();
const messageReceiver = new ServerSocketMessageReceiver();
const messagePublisher = new ServerSocketMessagePublisher();
-const messageProcessor = new ServerMessageProcessor();
+const messageProcessor = new ServerMessageProcessor(game, sessionManager);
-const game = new Game();
-
-const server = new GameServer(game, messageReceiver, messagePublisher);
+const server = new GameServer(
+ game,
+ messageReceiver,
+ messagePublisher,
+ sessionManager
+);
[
+ new SessionInputSystem(sessionManager),
+ new NetworkUpdate(messageReceiver, messagePublisher, messageProcessor),
new Physics(),
new Collision(new Grid()),
- new WallBounds(),
- new NetworkUpdate(messageReceiver, messagePublisher, messageProcessor)
+ new WallBounds()
].forEach((system) => game.addSystem(system));
+const floor = new Floor(160);
+const floorHeight = 200;
+
+floor.addComponent(
+ new BoundingBox(
+ {
+ x: Miscellaneous.WIDTH / 2,
+ y: Miscellaneous.HEIGHT + floorHeight / 2
+ },
+ { width: Miscellaneous.WIDTH, height: floorHeight }
+ )
+);
+game.addEntity(floor);
+
game.start();
setInterval(() => {
game.doGameLoop(performance.now());