Skip to content

favilances/nodejs-gameserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS 2D Game Server (Potato Throw)

This is a small authoritative Node.js game server for a simple 2-player web game. Players can move and throw "potatoes" at each other. The repository provides only the server code — you said you'll implement the web client later.

Files:

  • src/server.js - express + socket.io server entry
  • src/game.js - authoritative game logic, player & potato state, tick loop
  • test/client_sim.js - small simulation that connects two clients and throws potatoes
  • package.json - dependencies and scripts

How to run

  1. Install deps
npm install
  1. Start server
npm start
  1. (Optional) Run test simulation in another terminal
npm run test-client

Protocol (Socket.IO events)

  • Client -> Server:
    • join (name)
    • input ({left,right,up,down})
    • throw_potato ({x?,y?,vx,vy})
  • Server -> Client:
    • joined (initial snapshot)
    • state (players, potatoes)
    • potato_thrown (potato)
    • potato_hit (potatoId, victimId, hp)

Next steps you may want to implement in the client:

  • Render players and potatoes on a canvas
  • Send input updates at ~20 TPS
  • On mouse/click, calculate velocity and send throw_potato

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published