Responsive server-authoritative game architecture written in TypeScript.
Objective: Build a server-authoritative game architecture that maintains smooth, responsive movement, even over high-latency networks.
To achieve this, the game employs the following concepts:
- Server Authoritative Gameplay: The server validates and controls all game state, ensuring fair and consistent play.
- Server Reconciliation: Corrects discrepancies between the client and server states by adjusting the client's view.
- Client-side Prediction: Anticipates player actions locally, creating a seamless experience on the client side.
- Input Sanitation and Validation: Ensures that only valid and non-malicious inputs affect gameplay.
Socket.io and Speed: While Socket.io simplifies real-time communication, it has speed limitations. Ideally, this game would use a custom UDP-based protocol for optimal performance, but that is beyond the scope of this project.
To check if these are installed, run:
node -v
npm -v
-
Clone the Repository
git clone https://github.com/zvoverman/luchador-game.git cd luchador-gamme
-
Install Dependencies
npm install
For development, use the following command to run both the server and client with hot-reloading:
npm run dev
This command does the following:
- Client: Starts a TypeScript type-checking process (
dev:client:typecheck
) and anesbuild
watcher to bundle client code on changes (dev:client:bundle
). - Server: Uses
ts-node-dev
to watch and re-run the server code on changes (dev:server
).
To simulate network latency during development, run:
npm run dev:fakelag
To build and run the application in production mode:
-
Build the project:
npm run build
-
Run the production server:
npm run start
After running either the development or production build, you can access the game in your browser at: http://localhost:3000
...