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 entrysrc/game.js- authoritative game logic, player & potato state, tick looptest/client_sim.js- small simulation that connects two clients and throws potatoespackage.json- dependencies and scripts
How to run
- Install deps
npm install- Start server
npm start- (Optional) Run test simulation in another terminal
npm run test-clientProtocol (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
inputupdates at ~20 TPS - On mouse/click, calculate velocity and send
throw_potato