Networking A Game

Started by
9 comments, last by BCullis 11 years, 4 months ago
Okay so I'm taking this courses while I'm abroad and our final big project is to build a game (which is fine) and network it.

The latter is my concern. We had a lecture / lab on building a echo server in C which i got most of I guess. But now I'm not sure how I'm suppose to mold this to help me network my game.

The game is developed using a scripting language developed by the college (which has heavy hints of C++).

I'm not looking for you guys to 'do my homework for me' I'd just appreciate some step in the right direction.

If you need to know anything just let me know.
/********************************************************************************\
/**********************He Who Dares, Wins**********************************\
/********************************************************************************\
Advertisement
What genre is your game? Networking a chess game is very different than networking a FPS.
It's an FPS
/********************************************************************************\
/**********************He Who Dares, Wins**********************************\
/********************************************************************************\
Take a look at: http://gafferongames.com/networking-for-game-programmers/

It's an FPS


Wait a second. From a one lecture that teaches you an Echo Server, you're supposed to know how to program an FPS networked game? I think something is missing here. Is it just a 2 player game or a true multiplayer (ie, 2 - 16)?

FWIW, creating a truly robust FPS Networked game is PRETTY FRIGGING HARD. Now, you can create a protocol that runs good over LAN, but would do poorly over the internet that's not too difficult (not too difficult for someone who understand networking protocols at least).

BTW, there's a networking forum here that has loads of information that you may want to look over all the posts there.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)


[quote name='!Null' timestamp='1354038870' post='5004590']
It's an FPS


Wait a second. From a one lecture that teaches you an Echo Server, you're supposed to know how to program an FPS networked game? I think something is missing here. Is it just a 2 player game or a true multiplayer (ie, 2 - 16)?

FWIW, creating a truly robust FPS Networked game is PRETTY FRIGGING HARD. Now, you can create a protocol that runs good over LAN, but would do poorly over the internet that's not too difficult (not too difficult for someone who understand networking protocols at least).

BTW, there's a networking forum here that has loads of information that you may want to look over all the posts there.
[/quote]

yep you got it right.

We haven't been given the exact spec yet but i get the impression that a 1v1 would be enough but even if you got a 1v1 going it would be just as 'easy' to get more players going.

If i could get it working over LAN that would at least be a step. I do know a little about networking but if I'mhonest I don't really like doing it from a programmatic stand point.

I've been looking through some of the functions and stumbled through some networking functions


NetAcceptTCP();
NetClose();
NetConnectTCP();
NetCreateChannel();
NetCreateChannelTCP();
NetDataReady();
NetGetIP();
NetReceiveFrom();
NetReceiveFromTCP();
NetSendTo();
NetSendToTCP();
NetSetMulticastIP();
NetVarReceiveFrom();
NetVarReceiveFromTCP();
NetVarSendTo();
NetVarSendToTCP();
[/quote]

Also thanks I might move the post over. And i'll have a look a look through there too.
/********************************************************************************\
/**********************He Who Dares, Wins**********************************\
/********************************************************************************\

We haven't been given the exact spec yet but i get the impression that a 1v1 would be enough but even if you got a 1v1 going it would be just as 'easy' to get more players going.


That's not really true at all. If you know you're making a 2 player game (1v1), then you wouldn't (or at least I wouldn't) waste time on making it client server, you should just make it peer-to-peer.

If it were me, and for a school project (with a strict deadline), I'd design the 1v1 FPS game like this:
Every update sent will include the players position and velocity. If nothing substantial happens (player is just moving), then you send an update every x milliseconds (say 100 mS) to the remote player.
The Clients sends immediate updates for actions (Bullet Fired, item picked-up, bullet hit).
So, when one client gets an update from the other player, he ensures the player is where he's supposed to be, and gives him his current velocity. If a special action occurs, like bullet fired, he puts the bullet into his local world and starts to move it.

All bullet hits happen locally (so, if the local player see it hit himself, it happens, but if the local player see the bullet hit the remote player, it may not, if that remote player has actually moved on his local machine).

Anyway, that's the general idea I'd start with since it's fairly simple and shouldn't be too difficult to implement in a short amount of time. Of course, there are tons of other ways you could do this, and mine may not even be the bets for this situation, but just one I thought of.

Good luck.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)


That's not really true at all. If you know you're making a 2 player game (1v1), then you wouldn't (or at least I wouldn't) waste time on making it client server, you should just make it peer-to-peer.


You say that as if making it "peer-to-peer" would be easier than establishing a client-server model. In my experience, it's the other way around; If you run the game on the server, and treat clients as dumb input/output terminals, you greatly simplify the architecture of the network system, and there's a whole class of problems that you don't have to worry about (like cheating, or overly ridiculous sync issues).

@!Null

I have a video tutorial that demonstrates how one could design and implement a relatively simple networking system:



I'm doing this within the blender game engine, using python, but the concepts are the same no matter what languages/platforms you use.

Hope that helps

+---------------------------------------------------------------------+

| Game Dev video tutorials -> http://www.youtube.com/goranmilovano | +---------------------------------------------------------------------+

You say that as if making it "peer-to-peer" would be easier than establishing a client-server model. In my experience, it's the other way around; If you run the game on the server, and treat clients as dumb input/output terminals, you greatly simplify the architecture of the network system, and there's a whole class of problems that you don't have to worry about (like cheating, or overly ridiculous sync issues).


In my experience (having done both), I think it is easier to do p2p for 1v1 games, but that may not be the case with everyone. Hopefully, by the time the OP has to start developing it, he'll have a grasp on doing either method and can choose which he wants. BTW, I don't think he's going to be concerned with cheating for a class project.

I'll have to check out your video, it looks interesting, thanks!

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

Thanks guys for all the support. I'll continue to try to make this work and when I'm done i'll post the result (after its submitted otherwise It wont get marked at all)

Goran Milovanovic
Thanks I'll have a look at it :)
/********************************************************************************\
/**********************He Who Dares, Wins**********************************\
/********************************************************************************\

This topic is closed to new replies.

Advertisement