UDP Online Network Connection - Sample Project

Post your own tutorials, guides and demos.

Post » Mon Apr 26, 2010 3:57 am

Hey guys!

As i've told before, i was messing around with UDP code stuff. Never programmed in Python before, but after some research, i could adapt MasterMind UDP library (that's on Pygame site) to work with Construct.

So, It's a simple program, where server will move the red player, and client will move de blue one. Connection is done via UDP as said, but there is no optimization or prediction or etc here, just studying socket stuff. It's rough, but works. You can connect to external ip, if port is properly forwarded.

I will try to advance on my experimentations and refine this thing a bit more. At the end of post, the source code for Construct is attached. And below, some links about UDP in Python and in general gaming:

[url:1f8h547j]http://www.pygame.org/project-Mastermind+Networking+Lib-859-.html[/url:1f8h547j] - Mastermind Networking Lib on pygame.org, from wich my code is based uppon.

[url:1f8h547j]http://gafferongames.com/networking-for-game-programmers/[/url:1f8h547j] - To me, this one is a must-read article series. It covers the basics about game networking. take a look!

[url:1f8h547j]http://gafferongames.com/game-physics/networked-physics/[/url:1f8h547j] - From the same guy, it covers aspects like client prediction, and i think it's focused on a FPS approach


Cap file attached. Used Constructed 0.99.84.

[attachment=0:1f8h547j]udp sample.cap[/attachment:1f8h547j]
B
3
S
1
G
2
Posts: 16
Reputation: 857

Post » Mon Apr 26, 2010 4:06 am

Excellent work! Just downloaded it and it worked well. I like how you in-lined the library code so folks don't have to mess with custom Python builds.

[quote="frpnit":3bijxya3]Used Constructed 0.99.86.[/quote:3bijxya3]
I think this should be .99.84. :wink:

btw.. I stumbled upon pysage today which is a Python tool on top of pyraknet. May be worth a look.
http://code.google.com/p/pysage/
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Mon Apr 26, 2010 1:31 pm

[quote="scidave":1413fpmd]Excellent work! Just downloaded it and it worked well. I like how you in-lined the library code so folks don't have to mess with custom Python builds.[/quote:1413fpmd]

Besides that, It's easier to debug , since it's directly attached to Construct itself.

My code is pretty much novice friendly (at my point of view), maybe someone could understand the UDP connection basics just reading that (maybe not :lol: )

[quote="scidave":1413fpmd]btw.. I stumbled upon pysage today which is a Python tool on top of pyraknet. May be worth a look.
http://code.google.com/p/pysage/[/quote:1413fpmd]

Pretty interesting stuff. The actor's system seems interesting for applications that demands high levels of data traffic (thinking in games like battlefield, that support 32 or more players across the net).

[quote="scidave":1413fpmd]I think this should be .99.84. :wink:[/quote:1413fpmd]

Thanks, fixed. Now I've put some interesting links regarding UDP network gaming that worth a look!

- FRP -
B
3
S
1
G
2
Posts: 16
Reputation: 857

Post » Mon Apr 26, 2010 3:52 pm

[size=200:z98c1qsr]nn.nn.nnn.nnn PORT: nn[/size:z98c1qsr]

nevermind, router doesn't want to play along
B
2
S
2
G
3
Posts: 193
Reputation: 1,636

Post » Mon Apr 26, 2010 3:58 pm

Doesn't appear to do anything.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Apr 26, 2010 4:09 pm

[quote="Dataflashsabot":1gsg4rsk][size=200:1gsg4rsk]nn.nn.nnn.nnn PORT: nn[/size:1gsg4rsk]

nevermind, router doesn't want to play along[/quote:1gsg4rsk]

You can test locally on same machine if you want to, just open two program instances, in one you click on start server, and on another you put your lan address to connect.

Arrow keys doesn't work after clicking on buttons or input fields, I have to switch to desktop or another window and then switch back to program. It's a focus issue i don't know if it could be avoided.
B
3
S
1
G
2
Posts: 16
Reputation: 857


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests