Hi, So I am a really new to Godot and Game programming in general, so excuse if this is basic. I am basically trying to figure out if my design/thought process makes sense or if I am missing something (or is completely idiotic 🙂 ).
I am trying to make a grid based multiplayer game, think that there is a world map with a 2d 100x100 (or larger) grid. Each cell has terrain {rock/sand/wall/grass}, features {wood/food/herbs}, actors {characters/players/enemies}.
Each player/actor can move around and do actions on the features/actors, but for a given map the terrain is static.
My thought is to store this world state information on the server in 3 2d arrays:
- A dense 2d terrain array.
- A dense 2d feature array.
- A sparse/dense 2d actor array.
Then when a player joins he gets copy of the 2d terrain array (possibly a subarray depending on the size of the world)
and gets updates to the feature array, and the actor array (or at least sub-arrays consisting of his field of view), along with the player state {health, stats, hunger}.
The clients:
- Receive state updates based on their location.
- Update the rendering based on the changes to the state arrays.
- Make moves.
- Tell server what happened.
The server then:
- Queue up the moves requested by the client(s) (separate thread services the RPC from clients)
- Synchronizes client request queues.
- Performs the operations.
- sends updates to clients about world state (separate thread)
In addition the server would be running a similar loop with AI actors, whos moves get queued similar to the client but without the RPC calls.
This makes sense to me, there is no need for the server to have anything more than some logic synchronizing clients/ running through AI nodes and performing their actions, but does not seem very Godot-like. There is no need for any graphics, the whole world can be defined by a few state arrays. In addition because of this there would be no physics implemented on the server either, as the collision logic for the game would be custom based on the world state arrays.
I realize that this is biting off a-lot, but thoughts about if this approach makes sense would be appreciated. I figure most of the world state at least the 2d arrays / subarrays and updating would end up eventually being custom code in C++, with possibly the (feature/actor) contents of the cells being nodes. This whole thing is partially a project to get understanding of the Godot internals/C++/ networking/ server aspects.
Thanks for any thoughts