Jump to content
  • Advertisement
Sign in to follow this  
quack

write game before network code?

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'd like to write a client/server network action game. Is there ideas on how to write a basic game first and then break it up to client server, or do most people do both concurrenlty? I'd like to not have to run a server and client everytime when debugging when starting the project so i can get the basics working gameplay/graphics/input. edit [i do know this is possible with peer to peer] Thanks quack

Share this post


Link to post
Share on other sites
Advertisement
there are some gameplay mechanics [someone was asking here a bit ago about how they could have one player "block" the attack of another, but when the attacked player doesn't find out for maybe half a second it doesn't make attacking someone very satisfying to the person attacking [at worst they might see the attack work a full second later]] which are not possible in a multiplayer [over internet] setting, I'd suggest you do them together.

Share this post


Link to post
Share on other sites
I suggest setting up you're game design in such a way that there is no difference between client/server and local play. So even when you are playing single player, you have a game server and a client connected with it.
So, the local player then becomes just another network-player, but with really short ping [wink].

Share this post


Link to post
Share on other sites
i suggest you to write the engine in a way that you can easily check out the client code and compile the server code into a independent console application and build in a remote control so you can control the server from a remote control program

directly working in the console window is a no since this will lead to lags if you don t have a seperate thread for the console input/output

Share this post


Link to post
Share on other sites
Easiest is if the client and server can be compiled and run in the same program. Then a simple "F5" will debug both the client and server at the same time.

At the code, you could structure your client and server code to be polled, in a sense, calling a single "server->step()" and "client->step()" call per time through the main loop. You might also want to separate out client->render(), if you want to be able to step several clients but only render one of them (useful when testing multi-player locally).

Your code might look something like:


InputSystem * input = new InputSystem();
SoundSystem * sound = new SoundSystem();
GraphicsSystem * graphics = new GraphicsSystem();
LogSystem * log = new LogSystem();
NetworkSystem * serverNetwork = new NetworkSystem( GAME_PORT );
NetworkSystem * clientNetwork = new NetworkSystem( 0 );

Server * server = new Server();
server->setLogSystem( log );
server->setNetworkSystem( serverNetwork );
server->started();

Client * client = new Client();
client->setInputSystem( input );
client->setSoundSystem( sound );
client->setGraphicsSystem( graphics );
client->setLogSystem( log );
client->setNetworkSystem( clientNetwork );
client->started();

while( running ) {
input->dealWithOsEvents();
client->step();
server->step();
}


Some people like factoring all the "set" calls into a single struct or hashtable called an "operating environment" for the different program components, and pass this environment to all components so they can call each other easily. You can then create two environments, one for the server, and one for the client, to mimic the actual behavior once the programs are compiled as two separate binaries.

Similary, maybe each major system needs to be stepped when in the main loop; that could be done with a stepping service that steps a list of steppables -- you get the idea.

Share this post


Link to post
Share on other sites
thanks all! the server and client thing is great to put in one app. i was worried before about having to run two diff debuggers. The running a single player game like network is also prima.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!