Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Multiplayer racing game  (Read 4708 times)
0 Members and 1 Guest are viewing this topic.
Offline sinsro

Senior Newbie




Java games rock!


« Posted 2006-07-11 08:22:02 »

I am about to make a 2D top down racing game where players can compete against each others over Internet.

I made a similar game earlier, but that time I used a server, and this time I need to use a server-less approach for several reasons, connecting players directly.

I have no experience in how to set up a direct connection between two clients and let them exchange data, so I wonder what's the basic fundament needed from your experience?

Assume I already got the clients IP addresses (matchmaking will be solved through a third party solution).

I think I need both TPC and UDP. And my biggest worry is Firewalls. So, can anyone advice me a method that would work for most people on windows system out there? Keeping in mind this is an action game.

A code snippet showing how to get a stream bytes to the other client over UDP/TCP, as well as how to receive it, would be great.

Thanks Smiley

Offline Kova

Senior Devvie





« Reply #1 - Posted 2006-07-11 20:50:07 »

well, about firewalls, user will must allow the game to use the port if he plans to connect to matchmaking service so if you send game data on same port where matchmaking is sending it will work. The only problem with firewalls as I know are when you try to connect to computer without it doing anything, then you'll get blocked.
Offline Jeff

JGO Coder




Got any cats?


« Reply #2 - Posted 2006-07-11 21:14:40 »

Well, you could always user Darkstar Cool 
The SDK even comes with a complete match maker in source code.

Otherwise, your big issue is firewalls.  If you are using a server i na start-configuration then TCP is no problem  because out-going connection are almost always mapped for you.  UDP is also not a problem on modern home firewalls so long as you start from the client and send a packet to the server first to get it to auto-map the UDP port and then look at that packet to see what the mapped incomign UDP port was.

Peer to Peer is trickier.  You more or less cannot accept an incoming TCP connection behnind a consumer firewall unless you manually configure the firewall to map a port on the firewall to  a port  on the machine yo uare playing on.

There is a trick sometiems called "UDP punch through" or "UDP introduction" where you cna use a server to help two clients behind firewalls establish a P2P UDP connection.

But at the end of the day, you pretty much need a server to solve firewall issues no matter which way you do it.  Darkstar handles this for you and is a "star" type system.  Otherwise you might want to investigate JXTA and use their servers...

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sinsro

Senior Newbie




Java games rock!


« Reply #3 - Posted 2006-07-12 02:40:03 »

Well, you could always user Darkstar Cool 
The SDK even comes with a complete match maker in source code.

Otherwise, your big issue is firewalls.  If you are using a server i na start-configuration then TCP is no problem  because out-going connection are almost always mapped for you.  UDP is also not a problem on modern home firewalls so long as you start from the client and send a packet to the server first to get it to auto-map the UDP port and then look at that packet to see what the mapped incomign UDP port was.

Peer to Peer is trickier.  You more or less cannot accept an incoming TCP connection behnind a consumer firewall unless you manually configure the firewall to map a port on the firewall to  a port  on the machine yo uare playing on.

There is a trick sometiems called "UDP punch through" or "UDP introduction" where you cna use a server to help two clients behind firewalls establish a P2P UDP connection.

But at the end of the day, you pretty much need a server to solve firewall issues no matter which way you do it.  Darkstar handles this for you and is a "star" type system.  Otherwise you might want to investigate JXTA and use their servers...


Thanks, Darkstar sounds interesting. I am googling for it now. Do you have any pointers to some basic tutorials matching a couple of clients, then allowing them to interact directly?

This was going to be my original approach:

- I only have access to a simple Perl based server, so I planned to use it as a tracker for all connected clients
- A client can send two messages to the Perl script:
  1. List - get a list of all connected clients
  2. Remove [client] - When a connected client pings another client and finds it is not accessible, it will alert the server so it is removed. This makes sure the server does not need an active connection to the clients.
- Every time a client sends any command to the Perl script, it will be added to the list of connected clients
- All inter-client communication will go directly, the server only keeps track of who is connected, for more details each client must be asked.

Very simple approach. Should be stable, require little bandwidth, and also does not require me to be able to run anything else than standard Perl, which most hosts allow today.

What do you think of this approach? Could I set up a "punch through" from this scenario?

Thanks
Offline bahuman

Junior Devvie





« Reply #4 - Posted 2006-07-12 07:16:57 »

You're gonna love darkstar. It keeps track of all clients for you, and you can set up "listeners", so that all clients see whatever another client sends.

https://games-darkstar.dev.java.net/
And the forums are right here on this same forum:
http://www.java-gaming.org/forums/index.php?board=52.0
Offline sinsro

Senior Newbie




Java games rock!


« Reply #5 - Posted 2006-07-12 17:25:30 »

You're gonna love darkstar. It keeps track of all clients for you, and you can set up "listeners", so that all clients see whatever another client sends.

https://games-darkstar.dev.java.net/
And the forums are right here on this same forum:
http://www.java-gaming.org/forums/index.php?board=52.0

Sounds great. However, do you think it would work for an action game like a real time racer? Also, how about Firewall problems?

I downloaded the game Stomping Grounds, which is using the service, but was disappointed to see it is was not only a turn based game, but it even was unable to find the Darkstar server. So, a bit worried if this thing works in real life..?

I could not find any working multiplayer action games using Darkstar, to validate the technology. Any pointers would be appreciated Smiley

Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2006-07-12 19:42:23 »

You're gonna love darkstar. It keeps track of all clients for you, and you can set up "listeners", so that all clients see whatever another client sends.

https://games-darkstar.dev.java.net/
And the forums are right here on this same forum:
http://www.java-gaming.org/forums/index.php?board=52.0

Sounds great. However, do you think it would work for an action game like a real time racer?

Absoltuely.  Shawn's racing game, Cosmic Racer, is a Darkstar app.

Quote
Also, how about Firewall problems?

Since it does a star-netwowrk through the Darkstar back end, as long as the Darkstar backend isnt behind a firewall your fine.  By definition a comemrcial deploymeny back end like you might go to for hosting of you game wont be.

There *is* a limitation in the implementation of the UDP today that makes firewalls a problem, but that is considered a bug and will be gone by commerical release.
I downloaded the game Stomping Grounds, which is using the service, but was disappointed to see it is was not only a turn based game, but it even was unable to find the Darkstar server. So, a bit worried if this thing works in real life..?

Quote
I could not find any working multiplayer action games using Darkstar, to validate the technology. Any pointers would be appreciated Smiley

Shawn just released a tech demo for Cosmic Racer.  You can talk to him about his expereinces.  Im hoping to have him hosted out of our Alpha server when i have time to set that yp next week, after which you should be able to actually play it networked over the internet yourself.

Quote

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #7 - Posted 2006-07-12 20:44:06 »

Hi

in EA1 UDP is working, with the caveat that when the client is behind a NATed firewall, the client must send, to the server at least 1 message via udp before the server can successfully send any. This is because the NAT can't work out what to do with the incomming UDP datagram untll the client has sent one outbound.

I get my client to send some message that the server ignores, then after that it's all fine Smiley

Endolf

Offline sinsro

Senior Newbie




Java games rock!


« Reply #8 - Posted 2006-07-13 02:39:25 »

Shawn just released a tech demo for Cosmic Racer.  You can talk to him about his expereinces.  Im hoping to have him hosted out of our Alpha server when i have time to set that yp next week, after which you should be able to actually play it networked over the internet yourself.

Sounds good, I am very interested in his experiences.

So, if I understand correctly Darkstar gives Matchmaking for free, and then allow you to also connect directly client to client?

I think such a server-less approach is essential once the game gets going in my case, as my players will be in all parts of the world, and the lag of sending all data through Suns server might kill it...

I assume after the beta phase of Darkstar Sun will start charging for hosting. I am not really eager to put money into this as I am doing it just for my own education, but do you got any ideas if they will charge us, and roughly how much?
Offline sinsro

Senior Newbie




Java games rock!


« Reply #9 - Posted 2006-07-13 03:55:10 »

Oh, I guess the game mentioned above should be Cosmic Birdie, not Cosmic racer Wink
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #10 - Posted 2006-07-13 20:58:06 »

The Full name is something enormous  like "Cosmic Byride Auto-gyro <something> Racer", so it gets called many things.

Darkstar provides what looks like a virtual private LAN situation to the client API, but all communication flows in a star pattern through the server.  This is imprortant to commercial games for security reasons.

If you really want true peer to peer either run your own introductions server or use JXTA.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (108 views)
2017-09-30 02:57:34

theagentd (135 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (240 views)
2017-08-02 12:19:43

cybrmynd (238 views)
2017-08-02 12:18:09

Sralse (252 views)
2017-07-25 17:13:48

Archive (864 views)
2017-04-27 17:45:51

buddyBro (1007 views)
2017-04-05 03:38:00

CopyableCougar4 (1566 views)
2017-03-24 15:39:42

theagentd (1373 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!