sidebar features
sidebar content

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

Reply
 
Thread Tools
andrew-101's Avatar
andrew-101 andrew-101 is offline
Member
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 1,525
Well, here is the link: Creating a Server for a (Blender) Game
The updated tutorial was too large to post on the forum so I moved it to my website.
Here is the introduction to the tutorial:
Quote:
This tutorial will go over how to create a server in python (it doesn't matter what language your server is made in but python will benefit the Blender user), make the server communicate with our client (being the Blender game) and setting up our game to run online.
The tutorial is python heavy so before reading make sure you know some python (this tutorial is written for python 2.5x).Even though this tutorial is written intended for the Blender user the techniques are still beneficial and will work for any other application.
Enjoy it and post questions if you have them.

Last edited by andrew-101; 04-Nov-08 at 07:11.
#1   Old 06-Oct-08, 10:45   
Reply With Quote


Sammaron's Avatar
Sammaron Sammaron is offline
Member
 
Join Date: Mar 2007
Posts: 1,347
well, i don't really get it but good work! i was under the impression servers had to be purchased... don't they? I don't really get the internet
............................................
<<<Watching a ping pong match
<<<Watching a smokin hot chick run in circles.
<<<Trying to see his eye-brows
<<<Smokin hot chick found a trampoline.
<<<Beneful? Wanna go to the park? Beneful?

SAVE THE POLAR BEARS!!!
http://www.reverbnation.com/theregoesthestudio
http://www.myspace.com/sevendaysuntillnextweek
#2   Old 06-Oct-08, 13:33   
Reply With Quote
harveen's Avatar
harveen harveen is offline
Member
 
Join Date: Aug 2008
Posts: 173
Thanks. I'll be keeping an eye on this thread.

Here's another one I had bookmarked on network gaming:

http://blenderartists.org/forum/showthread.php?t=109123
#3   Old 06-Oct-08, 13:45   
Reply With Quote
Minifig's Avatar
Minifig Minifig is offline
Member
 
Join Date: Sep 2008
Location: America, Central time.
Posts: 2,971
Hey, is LAN networking possible?
I have several PC's at my house and all are linked up on a LAN network. We play games like Starcraft together, so why not a Blender game?
............................................
This is my sig.
Feel free to use my texture repository: http://www.cdupload.com/browse/Minifig/3913_FKSa1
Please don't call me mini.

Last edited by Minifig; 06-Oct-08 at 16:27.
#4   Old 06-Oct-08, 16:16   
Reply With Quote
andrew-101's Avatar
andrew-101 andrew-101 is offline
Member
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 1,525
I think so, you have to make the host in blender be the ip address of the machine that the server is running on, so instead of locahost 127.101.51 or something
#5   Old 06-Oct-08, 20:01   
Reply With Quote
J09's Avatar
J09 J09 is offline
Member
 
Join Date: Jan 2007
Posts: 1,441
Quote:
Originally Posted by andrew-101 View Post
I think so, you have to make the host in blender be the ip address of the machine that the server is running on, so instead of locahost 127.101.51 or something
My guess would be that for a local (within a single network) game, you would need to give it a local ip address. so 192.168.xxx.xxx (whatever is assigned by the router).
............................................
Resources
#6   Old 07-Oct-08, 01:31   
Reply With Quote
sundialsvc4 sundialsvc4 is offline
Member
 
Join Date: Jan 2004
Posts: 2,857
Every computer in any TCP/IP network ... like the Internet, or the network in your home ... has an IP-address. The address is, no doubt, a set of 4 numbers (each one in the range 0-255... that is to say, four bytes).

There are a few "special" addresses:
  • 127.0.0.1 always refers to "this box." It goes by the name "localhost," or is sometimes called a "loopback."
  • Addresses such as "192.168.xxx.xxx" are called non-routable addresses. That is, they always refer to "this network." The addresses of the various items within your home-network will be like this. (There are several designated groups of "non-routable addresses" to choose from...)

Your entire house has only one IP-address, though, as far as the Internet-at-large is concerned. That address is held by, and known only to, your "router." What the router does, then, is to distribute inbound and outbound traffic between "the Internet" and "your home network." (They are, and they remain, two separate networks. Your router serves as the so-called gateway between them.)

If you want to game within your home, it's easy: the IP-addresses are unique and they are confined to your home.

If you want to game with your neighbor, however, the traffic will have to go through two routers... yours, and your neighbor's. The trick is, you won't see the IP-addresses within your neighbor's network. Instead, the traffic will come from the (Internet...) IP-address of your neighbor's router, and a particular port-number, which is rather like a telephone "extension." (Port-numbers are assigned by the router, and they are actually "how routers know how to distribute the traffic.")

In a small game, the computers can talk directly to one another ... so-called peer-to-peer. But as the number of players increases, it becomes more efficient to route all the traffic to a central server, a so-called socket server, whose job is to maintain the state of the game and to send-and-receive appropriate notification messages from the players. In effect, the socket-server(s) "run" the game, while the individual client-computers manage the drawing of what you see.

There are many commercial socket-servers, but there are open-source ones too. The programming required to implement such a server is both "not trivial" and "highly repetitive," since it is the necessary-foundation upon which the game-specific logic is based. That's why you usually see games being constructed around such a foundation, and maintained by vendors who license them for their profit.

Last edited by sundialsvc4; 08-Oct-08 at 12:53.
#7   Old 07-Oct-08, 13:50   
Reply With Quote
-[Killer]-'s Avatar
-[Killer]- -[Killer]- is offline
Member
 
Join Date: Jan 2007
Location: Florida
Posts: 3,581
Ok all I want to do for now is a simple proof of concept IM.

All I need is to (it doesn't have to work in blender, just in terminal) to have a live session via: lan connection. All it has to do is this:

user1 = raw_input("User %: ")
user2 = raw_input("User %: ")

print user1
print user2

how would I get it to work right? (from there I'd just loop the script) It's for me and my brothers evergoing game project Jedi Battles (It's so we can have a python IM client run during the game [like STEAM])

Just PM me if you have the solution. (btw: it would be nice to print the date [ie: user1 entered the chatroom 1.3.2009 [8:30PM]])
............................................
Omg, I finally changed my avatar again! Yes, that's me With my guitar and before you ask, yes I have makeup on.

NEED MORE UPLOAD SPACE FOR YOUR BLENDER FILES? CLICK HERE TO GO TO THE BLENDER FILE UPLOADER!!!!!



Resources: Real-Time Motion Blur, Ragdoll, Maze AI, GeFX

Blender Artists Free Script Repository


Tower Siege 2


MEDIACHICKEN BLOG
#8   Old 07-Oct-08, 15:35   
Reply With Quote
andrew-101's Avatar
andrew-101 andrew-101 is offline
Member
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 1,525
Hey everyone,
(thanks for the info on ip addresses sundialsvc4)

I've been doing some more research on this and will be updating the tutorial and including an example of a chat system in blender and some better examples of structuring your game to work with a server.
#9   Old 09-Oct-08, 03:50   
Reply With Quote
curlystraw's Avatar
curlystraw curlystraw is offline
Member
 
Join Date: Mar 2008
Location: Somewhere you don't expect
Posts: 728
I've done this before, and I might wanna warn you, that "localhost" is well, local. My friend spent a frustrating week trying to get an interent connection to work. instead of "localhost" enter your computer name. That what you need for LAN anyway.
............................................
I scream, You scream, We all scream for.... Blender?!
#10   Old 09-Oct-08, 11:42   
Reply With Quote
B3D00's Avatar
B3D00 B3D00 is offline
Member
 
Join Date: Mar 2008
Posts: 2,428
Really cool, well done!
Quote:
Originally Posted by Sammaron View Post
well, i don't really get it but good work! i was under the impression servers had to be purchased... don't they? I don't really get the internet
Servers' anything that connect the internet, you need supercomputers to make a webpage for millions of people. For just two guys playing, you can use a normal computer.
............................................
Where to start in Python
#11   Old 09-Oct-08, 21:15   
Reply With Quote
linuxpimp21's Avatar
linuxpimp21 linuxpimp21 is online now
Member
 
Join Date: Jul 2006
Location: Western MA, USA.
Posts: 1,234
I am no expert but i think there is a difference between a hardware server and a software server. The hardware server is what is bought. A software server is like a background process on your computer that sits there and waits for clients to "serve" I can't explain it too much as it has been awhile since I've read about socket programming.
#12   Old 09-Oct-08, 22:59   
Reply With Quote
Moguri's Avatar
Moguri Moguri is offline
Member
 
Join Date: Jun 2008
Location: Spokane, Washington, USA
Posts: 795
Any computer can be a server. Those big fancy ones just do the job better. But I've got a 2.1ghz Athlon 64 X2 with one gig of ram acting as an SVN, Unreal Tournament, and what ever I feel like messing with server. Granted I don't run too much at once, like the UT server I usually leave off until I play.

Thanks for the info andrew-101. This will come in handy when I get around to tackling networking in my current project.
#13   Old 10-Oct-08, 05:33   
Reply With Quote
andrew-101's Avatar
andrew-101 andrew-101 is offline
Member
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 1,525
Well the software server is just a program to receive information and process commands then re send information.

In the update on the tutorial I will be using TCP sockets and threads.
#14   Old 10-Oct-08, 06:47   
Reply With Quote
andrew-101's Avatar
andrew-101 andrew-101 is offline
Member
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 1,525
Tutorial is updated
#15   Old 10-Oct-08, 14:02   
Reply With Quote
TheSambassador TheSambassador is online now
Member
 
Join Date: May 2008
Posts: 1,019
Quote:
Originally Posted by andrew-101 View Post
btw, there is a part in the script reciever in the client that goes like this:
Code:
if n == 1: lines[0].Text = GameLogic.chat_log[n - 1] elif n == 2: for i in range(0,2): lines[i].Text = GameLogic.chat_log[n - (i + 1)] elif n == 3: for i in range(0,3): lines[i].Text = GameLogic.chat_log[n - (i + 1)] elif n == 4: for i in range(0,4): lines[i].Text = GameLogic.chat_log[n - (i + 1)] elif n == 5: for i in range(0,5): lines[i].Text = GameLogic.chat_log[n - (i + 1)] elif n == 6: for i in range(0,6): lines[i].Text = GameLogic.chat_log[n - (i + 1)] else: for i in range(0,7): lines[i].Text = GameLogic.chat_log[n - (i + 1)]
If some one could shorten that down to a single for loop it please do and tell me, I couldn't get it myself.
Couldn't you do something like this?
Code:
if n == 1: lines[0].Text = GameLogic.chat_log[n - 1] elif n > 6: n = 7 else: for i in range(0,n): lines[i].Text = GameLogic.chat_log[n - (i + 1)]
I'm not sure what these lines that you've written would do, but you can very easily replace the tons and tons of if statements with just a for loop from 0 to n. I had the other cases just in case you needed the special cases of n==1 and n > 6.

Last edited by TheSambassador; 10-Oct-08 at 20:35.
#16   Old 10-Oct-08, 20:03   
Reply With Quote
andrew-101's Avatar
andrew-101 andrew-101 is offline
Member
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 1,525
The 'lines' are the lines that chat is displayed in, n is the length of the chat log (n = len(GameLogic.chat_log) ) I should of put that up top, so the code is checking how many lines there are then displaying the last message in line0, 2nd last on line1.
Quote:
for loop from 0 to n
Thank you! thats what I need.
#17   Old 11-Oct-08, 00:58   
Reply With Quote
dr-mad's Avatar
dr-mad dr-mad is offline
Member
 
Join Date: May 2008
Posts: 130
hi where do i put the server.py script in??
and on your client how do i type the pass in when i start up by the login???
#18   Old 15-Oct-08, 18:26   
Reply With Quote
andrew-101's Avatar
andrew-101 andrew-101 is offline
Member
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 1,525
You put the server.py script anywhere you want, just make sure its running when you start the blend.

Choose any user name you want, but just make the pass what the user was, so if I used 'andrew' as my user my pass would also be 'andrew'.
#19   Old 16-Oct-08, 08:44   
Reply With Quote
Sim88 Sim88 is offline
Member
 
Join Date: Aug 2006
Posts: 1,504
Quote:
Originally Posted by andrew-101 View Post
Well, heres the link: Creating a Server for a Game
The updated tutorial was too large to post on the forum so I moved it to my website.
Here is the introduction to the tutorial:
Enjoy it and post questions if you have them.
I get
Quote:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/tba/public_html/index.php:4) in /home/tba/public_html/libraries/joomla/session/session.php on line 413

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/tba/public_html/index.php:4) in /home/tba/public_html/libraries/joomla/session/session.php on line 413

Warning: Cannot modify header information - headers already sent by (output started at /home/tba/public_html/index.php:4) in /home/tba/public_html/libraries/joomla/session/session.php on line 416
Array ( [0] => option [1] => Tutorials [2] => creating-a-server-for-a-game.html )
when I click the link
............................................
Here is my thread for BGE demo files
#20   Old 16-Oct-08, 10:14   
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:01.


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