Skip to main content
GameDev.net gamedev.net
🔒 Locked

single + multiplayer game

Started by ErUs Feb 16, 2006 at 8:05 AM 6 replies 1.8k views
Original Post
ErUs
ErUs
hello, I am about to start work on a single and multiplayer game and i would like some advice on how to work this out. I figured i would need a like 2 seperate base classes - client and server. So the client would start and if needed, create an instance of server? is this the propper way todo it? and any other advice you can give?
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
toXic1337
toXic1337
I just got the network portion of my game finished. I used RakNet, but the concepts still apply. Here's what I did:

First, when I was designing my game I decided that the actual game would be client only. This made it a bit easier to program in my opinion.

I wrote a seperate app in a C++ console that handled what the clients sent to it and redistributes that information across the network.

So basically what happens is this:

1) I start the server up, It initializes all it's info.
2) Start the game, enter a server ip, and connect.

(this is where it kinda splits up a little)

3) Client sends updates in position along with other things to server.
4) Server receives this packet, and redistributes across the network.

(to eliminate lag)

5) Client receives enemies first packet and sets position, from then on it only updates velocity (not position). Then every 333ms, I update the enemies to their "true" positions.

Honestly though, in the end it doesn't matter how you do it. This is just how I did mine. Technically, any method will work as long as it is valid. It's just that some methods are more efficient than others.

The thing that helped me the most was to shut your computer off. Really. Take out your pencil and paper, and actually think through how your clients and server are going to talk to each other. Make yourself a nice pretty flowchart and then start coding. Sounds silly, but it works.

Coming to the table with a solid plan is necessary. Well, I think I've trekked far enough off topic so...

I hope this helped,

toXic~
toXic1337
ErUs
ErUs
thanks toxic,

i am planning to use raknet, i find it good and easy to use.

i would like to know a bit more about how a client can play single player without having to start a seprate server program and connecting to it. what methods are used for this?
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )
bitplane
bitplane
just put a wrapper round all your input functions, so there's like an emulated network server built into 1 player mode. the kind of structure you'd use for recording and playing back demos, redefining inputs etc
toXic1337
toXic1337
@ErUs:

Could you elaborate a little more on what type of game you're making. It's hard for me to understand what you mean by single player when all I can think of in reference to multiplayer is a "Counter-Strike" type game.

Perhaps you mean how you would split up like a single player campaign with a story and the multiplayer pvp aspects? If that's the case, you're going to end up with two very different games wrapped into one.

They of course would pull on the same core data such as maps, character models, etc.

Elaborate a little bit more.

toXic
toXic1337
Bob Janova
Bob Janova
I'm thinking something along the lines of Quake II, where a 'single player' game creates an instance of the server, with a different ruleset, and connects to it in the usual way. That would contain all the code within the server section and its various rulesets, with the client code being relatively simple and just handling UI and display.

Without knowing more about the game you're planning, though, I can't be more specific.
ErUs
ErUs
yes correct :D
-www.freewebs.com/tm1rbrt -> check out my gameboy emulator ( worklog updated regularly )

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.