Jump to content
  • Advertisement
Sign in to follow this  
breakspirit

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

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

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
Advertisement

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.



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
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!