Sign in to follow this  
jamesleighe

Singleplayer / Multiplayer Approach

Recommended Posts

jamesleighe    222
So, the game will have a singleplayer and a multiplayer.

I was thinking of making a client and a server and even in singleplayer you host a server and connect with your client to simplify the codebase.
The problem is that so many things are allot less efficient with this model and like twice the memory is used for some things...

I could make a special singleplayer 'client' that integrates the server and client but that seems like allot of maintenance work when something changes.

How would you guys do it?

Thanks!

Share this post


Link to post
Share on other sites
6510    151
In singleplayer mode I only exchange the network components by using a direct in-memory approach instead of TCP or UDP.
The game's core with its client and server components stays the same.

Share this post


Link to post
Share on other sites
jamesleighe    222
The only issue (that may be somewhat unavoidable) is that I have to store two instances of the same information (position of objects for example).

This can get bad if for example I was using dynamic terrain and had to store terrain data twice.

Share this post


Link to post
Share on other sites
In.Vain    108
These are your options:
1. Do nothing and ask your potential customers to upgrade their RAM.
2. Reduce the memory requirements of your software until you are happy with storing all necessary data as often as it is necessary.
3. Create a third mode of execution that calls the server- and client-subfunctions on one single set of data.

Regarding the third option:
The main server function does these things:
a) Receive user input from clients.
b) Apply game rules to the game state.
c) Broadcast changes of the game state to clients.

The main client function does these things:
a) Receive updates of the game state from the server.
b) Collect user input.
c) Send user input to the server.
d) Apply (local) game rules to the (local) game state.
e) Render the local game state.

(There are a few other things, but let's truncate that.)

The ServerClientMix-Thing is supposed to do the following:
a) Collect user input.
b) Apply game rules to the game state.
c) Render the game state.

If you reordered your main server- and client functions so that the three main sub-functions of the ServerClientMix-Thing were member functions of neither the client nor the server it'd be easy to create the ServerClientMix-Thing as a seperate entity.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this