Hey,
I’m making a 4K game, and it’s gonna be multiplayer. I need a very simple, effecient and very slim code doing the client/server functionality.
Since I’ve never done any game networking, I’m wondering if it was a good way to start by looking at some existing games doing the same?
My idea is somewhat like this:
A# Joining a game
- Client connects to server > Server accepts
- Client requests map ID -> Server sends map ID -> Client generates map
- Client requests current game state status (list of players and their score, gametime etc.) -> Server sends state
B# When done joining the game, the following is repeated continiously
- Client tells server where he is located (x,y) -> Server mediates to all clients
- Server sends info on state of all players.
- Repeat B#1
C# In case of some events performed by either the client or server.
- Server sends end-game-signal to all players after X time -> Client displays scores list for few seconds and Server resets itself and finds a new map ID -> Client can reconnect again, if he does -> Start A#1
- Player fires his rocket -> Client sends rocket location to server -> Server sends location of rocket to all clients -> Enemy clients determine if they are hit, if so -> Enemy client subtracts health from himself (or destroys himself if low on health) -> Notify server of change -> Server updates game state info.
Something like that.
Thank you.