Jump to content
  • Advertisement
Sign in to follow this  
RandyJohn

Playing alone's no fun! A design issue...

This topic is 4330 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

If I am to develop a simple bird's eye tile based shooter for single play and multi play, how do I go about designing client/servers etc. Within my game, I have a GameEngine class, a GameMaster class (static stuff like Graphics Adapters and Particle lists etc.) and player, particle bullet classes etc. How should I design it such that I can retain most of my current code and be able to multiplay, so's that a person can host a game and play at the same time. Where does 'stuff' go? Does the GameEngine's update function send & receive data to & from other GameEngine classes on other PC's? What's the general setup for this sort of thing?

Share this post


Link to post
Share on other sites
Advertisement
The Forum FAQ has a number of resources. In general, your problem has been solved in the past by creating a "server" and a "client" inside the game process, even in single-player mode.

Share this post


Link to post
Share on other sites
Another approach which I've used for small (low-graphics, but I don't think that's particularly important for the question) games is to separate out the input and output parts of the game into abstract interfaces. Then you have an input class controlled by the mouse and the keyboard, and a different one which takes messages over the network. Both of them generate player commands, and a character in the game is controlled by a particular input device – the game engine doesn't care (or even know, perhaps) whether it's controlled from here or there.

When running the server, your character is controlled by a LocalInput, computer-controlled ones by a ComputerInput and networked ones by a RemoteInput. When running a client, everything is controlled by RemoteInputs, but you also have a LocalInput which is hooked up to send its commands to the network instead of your local game engine. (Though in a fast game the client's local game engine will want some blend of input for the player's character so it doesn't seem really laggy.)

This may not be appropriate for games where a lot of things are not controlled by player commands and a lot of game state needs to be passed around. To pass 'stuff' around your server game engine needs to be able to broadcast 'stuff' to all the connected clients, and clients need to be able to read 'stuff' off the network and integrate it with their local state. It works very successfully for a turn-based card game, and I do realise that's a different sort of game to yours!

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!