sidebar features
sidebar content

Go Back   Blender Artists Forums > Game Engine > Game Engine Resources

Reply
 
Thread Tools
morgade's Avatar
morgade morgade is offline
Member
 
Join Date: Aug 2006
Posts: 24
After studying python network libs, I made this template (still work in progress !!).
This demo is already a fully functional example of a networked multiplayer game (using server X thin client architecture).

A brief explanation of the architecture is here
This demo is a 3D Pong, where two players can be at diferent computers in the internet

How to test in one machine:
  1. Open and run the server first. It will start listening two connections. Blender will freeze because this is a blocking operation. Let it opened. (Multi-threading python is causing Blender crash in my machine)
  2. Open another Blender with the client and run it. This Blender will connect via TCP to the Blender server. Again, this new Blender will freeze because we need to wait the second client/player to start the game (this synchronization is done by blocking TCP reads)
  3. Open a third Blender with the client. When you run it, this third Bender will connect to the server and the game begins !!! Try to put the windows side-by-side to see the fast syncrhonization achieved using UDP messages
  4. Use W, S, A, D keys in the two clients to see how the state is spawned to server and the clients. Ball physics is spawned automatically !
For now, to test in networked machines you need to change the IP adresses in the scripts. Remember to always start the server first ! The network protocol is the python serialization function in the module "pickle".

To python prgrammers: Discover how one client can "cheat" the server in this example

(I think you really need python installed to this work)
Server blend: http://uploaded.to/?id=we92g8
Client blend: http://uploaded.to/?id=m0gmfg

I'll try a tutorial on this when completed.
UPDATED: Server now tracks score and clients are textured and has shadows. Now I'll try to make multi-threading connection works
Attached Images
File Type: jpg net.jpg (109.0 KB, 232 views)
............................................
* Don't laugh ! English is not my first language ...

Last edited by morgade; 03-Nov-08 at 17:32. Reason: Links updated by request
#1   Old 15-Jul-07, 07:05   
Reply With Quote


braveheart's Avatar
braveheart braveheart is offline
Donating Member
 
Join Date: Apr 2006
Location: Scotland
Posts: 995
Yes for it to work you need Python 2.5 (as you do for mine). I also noticed that blender freezes if the server is a .exe, you should make the server just a Python module, that way you can just run it as it's own console no need for blender.

Hmm, maybe you could help me with sycing zombie/door/bullet (from a gun ) movement?

Thread: http://blenderartists.org/forum/showthread.php?t=100617


Please upload elsewhere! I hate rapidshare you need to wait an hour between downloads!
............................................
Training to become a Police Officer.
Hobbyist programmer.
#2   Old 15-Jul-07, 09:55   
Reply With Quote
James XVI James XVI is offline
Member
 
Join Date: Nov 2006
Location: In the most peaceful country ever....
Posts: 950
Quote:
Originally Posted by braveheart View Post
Please upload elsewhere! I hate rapidshare you need to wait an hour between downloads!
Are you sure about that? I just downloaded both? Took 15 secs...
#3   Old 15-Jul-07, 12:16   
Reply With Quote
morgade's Avatar
morgade morgade is offline
Member
 
Join Date: Aug 2006
Posts: 24
UPDATED: Server now tracks score and clients are textured. Now I'll try to make multi-threading connection works

[Oups... Textures where not packed]

Server blend: http://uploaded.to/?id=i4jwnm
Client blend: http://uploaded.to/?id=ra9u5f

Quote:
Hmm, maybe you could help me with sycing zombie/door/bullet (from a gun ) movement?
I'll look it.
............................................
* Don't laugh ! English is not my first language ...

Last edited by morgade; 15-Jul-07 at 18:36. Reason: Textures where not packed
#4   Old 15-Jul-07, 16:32   
Reply With Quote
blendenzo's Avatar
blendenzo blendenzo is offline
Moderator
 
Join Date: Apr 2006
Location: Michigan, USA
Posts: 2,193
It works great on my PC. I don't have a setup to be able to test it on a network right now, but I'm curious to hear what kind of results it give.

A couple of things:
You forgot to pack the textures (looks nice in the screens, though).
The game currently doesn't recognize when one client quits or the connection is lost, so the remaining player might continue for a little while wondering if the other person is still there.
............................................
Game Engine tutorials: blendenzo.com - 3DKernel - TutorialsForBlender3D - blending-online
My Projects: Solomon's Treasure - Sokoban - Marble Labyrinth
#5   Old 15-Jul-07, 18:33   
Reply With Quote
morgade's Avatar
morgade morgade is offline
Member
 
Join Date: Aug 2006
Posts: 24
Quote:
You forgot to pack the textures (looks nice in the screens, though).
I noticed the textures where not packed. Just uploaded a packed version now.

Quote:
The game currently doesn't recognize when one client quits or the connection is lost, so the remaining player might continue for a little while wondering if the other person is still there.
I know. The server must detect when one client disconnects and send a special message to the remaining client signaling the end of the game. These synchronization issues are the ones that demands more coding. Also, I'm having problems starting new python threads (the threads don't start or Blender crashes)
I will pack this simple version to people study and will try to implement the synchronization code.
............................................
* Don't laugh ! English is not my first language ...
#6   Old 15-Jul-07, 18:48   
Reply With Quote
ragchan's Avatar
ragchan ragchan is offline
Member
 
Join Date: Dec 2006
Posts: 141
It works fine for me with blender 2.43 and python 2.4. Its really cool, and if you made a tutorial, you would be awsome in my book.
............................................
Whats a Signature......?
#7   Old 15-Jul-07, 19:01   
Reply With Quote
Mmph! Mmph! is offline
Banned Member
 
Join Date: May 2007
Posts: 3,020
God this might be exactly what we are looking for!

could this be expanded to like 4 players?

p00f and I are planning on a chess game, where the pieces settle the the disputes in a 3rd person death-match in various arenas,
(based ancient commodore 64 game by the first Electronic arts, Archon, and Archon 2)

Man, I got to see if we can try this at work on the LAN!

thanks for making this
#8   Old 15-Jul-07, 19:29   
Reply With Quote
braveheart's Avatar
braveheart braveheart is offline
Donating Member
 
Join Date: Apr 2006
Location: Scotland
Posts: 995
Quote:
Originally Posted by morgade View Post
I'll look it.
What do you mean?
............................................
Training to become a Police Officer.
Hobbyist programmer.
#9   Old 15-Jul-07, 20:12   
Reply With Quote
Thorgal's Avatar
Thorgal Thorgal is offline
Member
 
Join Date: Sep 2003
Location: Brazsil
Posts: 568
Hey, very cool.

Sadly i was not able to play. I click inside the blender clients and "wasd" doesn't work... But Blender tell that "conections" are ok (server was able to "catch" clients). :S

Using python 2.5 and Blender 2.44

Later i will try Blender 2.43 and python 2.4 like Ragshan did.

Congratulations for the excelent work!
............................................
www.primotico.blogspot.com

#10   Old 15-Jul-07, 20:41   
Reply With Quote
morgade's Avatar
morgade morgade is offline
Member
 
Join Date: Aug 2006
Posts: 24
Quote:
could this be expanded to like 4 players?
Yes. It's all about plain python programming. The server can handle a list of clients (with sockets and addresses), and send messages to all clients in the list.
One important first step is define the comunication protocol between client and server (put it on paper to not get lost). I'll put this in the tutorial
I tried it in a LAN (actually two PCs connected by a cross-cable), and worked fine

Quote:
What do you mean?
I mean I will try help with your problem later (Sorry ... Read my signature)
............................................
* Don't laugh ! English is not my first language ...
#11   Old 15-Jul-07, 20:42   
Reply With Quote
braveheart's Avatar
braveheart braveheart is offline
Donating Member
 
Join Date: Apr 2006
Location: Scotland
Posts: 995
Quote:
Originally Posted by morgade View Post
I mean I will try help with your problem later (Sorry ... Read my signature)
Great! I really hope you can help.

Blender also froze for me and never worked, i'm using blender 2.44 & Python 2.5.
............................................
Training to become a Police Officer.
Hobbyist programmer.
#12   Old 15-Jul-07, 20:45   
Reply With Quote
rowboat rowboat is offline
Member
 
Join Date: Jan 2007
Posts: 44
I followd your directions but i still cant get it to work, all that happens is the server runs but then its says invalid syntax socket?
#13   Old 16-Jul-07, 03:53   
Reply With Quote
morgade's Avatar
morgade morgade is offline
Member
 
Join Date: Aug 2006
Posts: 24
Quote:
Originally Posted by rowboat View Post
I followd your directions but i still cant get it to work, all that happens is the server runs but then its says invalid syntax socket?
Can you post the complete error message ?
............................................
* Don't laugh ! English is not my first language ...
#14   Old 16-Jul-07, 11:43   
Reply With Quote
PlantPerson's Avatar
PlantPerson PlantPerson is offline
Moderator
 
Join Date: May 2002
Location: Milky Way Galaxy
Posts: 5,052
OMG this is just waht i need make raelly cool mmorpg... i am making team will people pls sign up help make my game? Thanks!!!111!!!!111 lolz

Just kidding...
This is really great morgade (although I don't think I can test it), thanks a lot for this excellent contribution to the BGE community. This makes a great addition to Social's FPS and Walkthrough templates. Maybe in the future we'll have more templates and therefore fewer stupid questions? All we need now is the "raelly cool game" template...
............................................
"Boy meets girl, girl meets boy.......boy asks 'what to do next' on 3d artists forum." - M@dcow
"I'm so tired of all my actions having consequences!" - T-rex, Dinosaur Comics
Into The Titan | Sunrise: A Webcomic | Art ~ ENOUGH WITH THE ZOMBIES
#15   Old 16-Jul-07, 11:50   
Reply With Quote
chuzzy06's Avatar
chuzzy06 chuzzy06 is offline
Member
 
Join Date: Feb 2006
Location: Massachusetts
Posts: 356
Quote:
Originally Posted by PlantPerson View Post
OMG this is just waht i need make raelly cool mmorpg... i am making team will people pls sign up help make my game? Thanks!!!111!!!!111 lolz
OH NO..PlantPerson = noob
Quote:
Originally Posted by PlantPerson View Post
Just kidding...
PHEw

This multiplayer template is a great idea! as far as i know this is the first time it was made( I know it was thought of more than once). Also, nice choice of pong for a template, its simple and anyone who wants to learn networking in blender can easily do so with this.
............................................
ChuZzy09
#16   Old 16-Jul-07, 13:58   
Reply With Quote
Olm-Z's Avatar
Olm-Z Olm-Z is offline
Member
 
Join Date: Apr 2006
Location: Bxl - Be
Posts: 280
hmmmm ... I think that you mised the BZoo (alias BlenderZoo) template, which is working pretty well allready !

the only thing is that I never been able to have the server noticing the disconnection of players when running on Linux, so I left it where I was with it last year ....

But I think it could be corrected by some python guru out-there ...
#17   Old 16-Jul-07, 15:07   
Reply With Quote
C-106 Delta's Avatar
C-106 Delta C-106 Delta is offline
Member
 
Join Date: Sep 2006
Posts: 1,259
This worked Perfectly on my computer. Great work. This is REALLY GOOD. Super fast framerate too.
It seems to work on blender 2.42a and blender 2.43. (with python 2.4).
............................................

#18   Old 16-Jul-07, 16:45   
Reply With Quote
alienkid10's Avatar
alienkid10 alienkid10 is offline
Member
 
Join Date: Jan 2008
Location: blender
Posts: 1,003
When I try to run it from my computor ro my bros with the server runing on mine it gives him a massage in the console saying "no attebte 'myid'" what do I do?
#19   Old 03-Apr-08, 23:39   
Reply With Quote
B3D00's Avatar
B3D00 B3D00 is offline
Member
 
Join Date: Mar 2008
Posts: 2,428
Cool! I always wanted to figure that out.
............................................
Where to start in Python
#20   Old 03-May-08, 16:55   
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 18:59.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Logo and website design copyright © 2006 by froodee design bureau. All rights reserved.
Other Blender Sites
new icon Blender Homepage »
The official Blender homepage
new icon BlenderNation »
Fresh Blender News, Every Day
new icon Blenderart Magazine »
Blender articles, tutorials and images.
Blender Headlines
Featured Artwork
Short animation: Barrel by Phlopper
Woolly mammoth by sebastian_k
Photorealistic classic furniture by eMirage
Social BlenderArtists