simple multiplayer FPS

Blitz3D Forums/Blitz3D Beginners Area/simple multiplayer FPS

Steven Noyce(Posted 2006) [#1]
Ok, I understand the basics of both multiplayer and first-person-shooters. My question is, how do I combine them?

How do you send the positions of bullets ext.?

A realy simple example of this would be greatly appreciated!!!


LineOf7s(Posted 2006) [#2]
There aren't too much in the way of simple examples, as it's not a particular simple concept. However, if you're into learning from other people's well-commented code (and if you're not, you should be), then here's an excellent example from the exceedingly generous Jeremy Alessi.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1142


Steven Noyce(Posted 2006) [#3]
Thanks, I am sure that will help me out eventually, but right now I think that that is a littlebit too advanced for me. I know that this is not a simple consept, but surely there is more simple example out there, mabe one that just uses startnetgame instead of gnet?


Steven Noyce(Posted 2006) [#4]
Oh, and I tried that example and it says "Failed to Create Server" when I try to create my own game. When I try to join a game, it just sits there and doesn't do anything.


Steven Noyce(Posted 2006) [#5]
Why do the bullets not match up with the target if you aim different directions in this little example of mine?

http://www.freewebs.com/blitznerd/FPS/FPS.zip


LineOf7s(Posted 2006) [#6]
Granted, that didn't work quite as well as it used to. Was a fun lil game too - not sure what changed, but the problems I'm having seem to be GNet-related... like the files it's looking for on the blitzbasic.com server are... in different places to where they were, or malformed... or something. Still, knowing that it worked fine means it's not unuseful for poring over to learn how to combine an FPS with netcode.

The thing is, there are plenty of examples around on how to do working netcode, and how to do FPSes. If you know how to do the FPS stuff, then adapting one of the 2D netcode methods should be (relatively) a doddle. If you aren't too comfortable with coding a 3D FPS but know all about netcode, then you have bigger fish to fry before you need to worry about adding network multiplayer.

Back to the code supplied though: I know it works (as I said, I've played it more than once), so if you just ignore all the GNet stuff (which only involves adding and listing servers from the remove masterserver, and none of the nitty gritty) then you'll find a great deal in there about how to "send the positions of bullets" etc.

You can also check out the netcode example that comes with BlitzPlay Lite (available here) - but again, you're going to have to study source code. This one doesn't involve GNet at all. Nor does the example netcode that comes with Blitz3D itself (in the command reference).

I have a sneaking suspicion though that there are probably a couple of things you could work on before you tackle implementing network multiplayer in an FPS.


LineOf7s(Posted 2006) [#7]
Clicking on that link opens a copy of this thread (?)


Steven Noyce(Posted 2006) [#8]
I know, I don't know how to do links in this forum.??
If you copy and paste the url into your browser it should work.


Steven Noyce(Posted 2006) [#9]
This code runs very slow on my network. It has fine frames per second on both computers, but it takes about two minutes to register what happened on one computer on the other.
Does anybody know why it is so slow?
How can I make it faster?



_PJ_(Posted 2006) [#10]
Try adding Delay 1 at the start of your main loop.


Steven Noyce(Posted 2006) [#11]
Why does that help?


Steven Noyce(Posted 2006) [#12]
Ok, I tried that, and it goes a bit faster, but the network still slows down about 9 seconds per minute that the game runs. Any other usefull tricks?


Steven Noyce(Posted 2006) [#13]
I think that I am going to switch from DirectPlay to UDP. I have looked through some code and things and I think that I understand the basics of how to use UDP. There is one thing I am not sure about, is there a way to brodcast a UDP message? If not, then how do I get all of the participating players IP addresses?

A simpe fps exampe like the one that follows (that doesn't work, it is just to show you what I am after) would help me a LOT!!!
sendudpstream=CreateUDPStream()
recvudpstream=CreateUDPStream()

;set graphics

;load stuff

;main loop

message$=blablabla ; your message
WriteLine sendudpstream,message
SendUDPMsg sendudpstream,destip

recvmessage=RecvUDPMsg(recvudpstream)

;interpret the message

;end



Wings(Posted 2006) [#14]
hmmm this seams to work..


http://server.voidrpg.com/network test2.rar