diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/constants.ts | 2 | ||||
-rw-r--r-- | server/src/main.ts | 6 | ||||
-rw-r--r-- | server/src/network/MessageProcessor.ts | 10 | ||||
-rw-r--r-- | server/src/network/SessionInputSystem.ts | 2 |
4 files changed, 14 insertions, 6 deletions
diff --git a/server/src/constants.ts b/server/src/constants.ts index a2b3d12..2968d3a 100644 --- a/server/src/constants.ts +++ b/server/src/constants.ts @@ -1,6 +1,6 @@ export namespace Constants { export const SERVER_PORT = 8080; - export const SERVER_TICK_RATE = (1 / 60) * 1000; + export const SERVER_TICK_RATE = (1 / 120) * 1000; export const GAME_TOPIC = 'game'; export const MAX_PLAYERS = 8; } diff --git a/server/src/main.ts b/server/src/main.ts index 0e47491..ece6823 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -30,9 +30,9 @@ const server = new GameServer( ); [ + new Physics(), new SessionInputSystem(sessionManager), new NetworkUpdate(messageReceiver, messagePublisher, messageProcessor), - new Physics(), new Collision(new Grid()), new WallBounds() ].forEach((system) => game.addSystem(system)); @@ -44,9 +44,9 @@ floor.addComponent( new BoundingBox( { x: Miscellaneous.WIDTH / 2, - y: Miscellaneous.HEIGHT + floorHeight / 2 + y: Miscellaneous.HEIGHT - floorHeight / 2 }, - { width: Miscellaneous.WIDTH, height: floorHeight } + { width: Miscellaneous.WIDTH / 2, height: floorHeight } ) ); game.addEntity(floor); diff --git a/server/src/network/MessageProcessor.ts b/server/src/network/MessageProcessor.ts index 2d9f11f..c133f67 100644 --- a/server/src/network/MessageProcessor.ts +++ b/server/src/network/MessageProcessor.ts @@ -29,8 +29,16 @@ export class ServerMessageProcessor implements MessageProcessor { session?.inputSystem.keyReleased(message.body as string); break; } - default: + case MessageType.UPDATE_ENTITIES: { + const entityUpdates = message.body as unknown as EntityUpdateBody[]; + entityUpdates.forEach(({ id, args }) => + this.game.getEntity(id)?.setFrom(args) + ); break; + } + default: { + break; + } } } } diff --git a/server/src/network/SessionInputSystem.ts b/server/src/network/SessionInputSystem.ts index 44fba54..0f7ca6f 100644 --- a/server/src/network/SessionInputSystem.ts +++ b/server/src/network/SessionInputSystem.ts @@ -1,7 +1,7 @@ import { Game } from '@engine/Game'; import { SessionManager } from '.'; import { System } from '@engine/systems'; -import { BoundingBox, ComponentNames, Control } from '@engine/components'; +import { ComponentNames } from '@engine/components'; export class SessionInputSystem extends System { private sessionManager: SessionManager; |