Sign in to follow this  
breakspirit

Best way to integrate networking(raknet) into game flow?

Recommended Posts

Hi guys, I'm working on using Raknet in conjunction with Ogre and I want some input as far as how networking(client/server) should be integrated into a main game loop.

Here's an incredibly basic overview of the program flow as I currently envision it

main game loop
{
Detect user input and do whatever needs to be done with it

Game logic such as calculating movements of npcs and other changes to the world

networking loop(grabs packets and sends out new ones indicating change to game state based on input and game logic)
{
}

draw the graphics according to current game state
}

I'm torn as far as whether the netcode should be in its own class. I know this is generally preferable, but I think that in the case of raknet, it may be unnecessary and complicate things. The way raknet grabs packets as they come in within a for loop and then executes actions based on the input makes it hard for me to see how to make it a class very easily.

I'll keep reading about it, I was just hoping someone on here could give me some input from a more experienced point of view. Thanks.

Share this post


Link to post
Share on other sites
[quote name='breakspirit' timestamp='1317849070' post='4869553']
I'm torn as far as whether the netcode should be in its own class. I know this is generally preferable, but I think that in the case of raknet, it may be unnecessary and complicate things.

[/quote]

Generally, you want "simulation" to be a different class from "presentation." Additionally, you want "input" to be input data to the "simulation." From the "network" you may receive "input" for the "simulation" of various game objects. Those "inputs" may be full state dumps -- making "simulation" do simple dead reckoning, or more analogous to user inputs -- making "simulation" do the same thing given the same inputs on each machine.
You probably also need an "entity" class that contains references to the simulation (or perhaps "input consumer") component and the presentation (or perhaps "display tick reactor") component and any other components you may want.

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