View Full Version : [AS3] Multiplayer Game?
Michael_Anthony
07-07-2009, 09:53 PM
Hi,
Anyone know of a good tutorial explaining how to connect two users to each other for multiplayer action? :)
Is this even possible? Does it have to go through a server?
I'd like to create a multiplayer game where people can connect to each other and play....but don't really have a clue how to get started doing this in Flash. I'd like to use AS 3.0.
Any help would be great! Thanks!
TomMalufe
07-07-2009, 09:58 PM
Yes it's very possible. here are some resources to get started:
http://www.actionscript.org/resources/articles/871/1/Creating-multi-player-game---TicTacToe/Page1.html
http://www.actionscript.org/resources/articles/881/1/Andrograde-and-Gamantra-announce-partnership/Page1.html
About Andrograde
Andrograde, LLC (http://www.andrograde.com) is a social casual flash game company based in silicon valley, California. Established in 2008, Andrograde offers a platform dedicated to helping developers monetize their games through virtual goods and social features. The Andrograde website is also a casual games social network for developers and players.
About Gamantra
Gamantra (http://www.gamantra.com) is a game technology and a full game development outsourcing company currently located in Shanghai, China. Established in 2006, Gamantra is committed to bringing the best networking engine and game server deployment platform to the social apps and gaming industry.
Tilpo
07-07-2009, 09:58 PM
Yes it's possible, but it's really difficult to do.
There are two possibilities actually:
Connecting directly to an IP of another user.
Connecting to as server which connects users with each other
Both options require intermediate knowledge in other programming languages, and the second one requires a server which supports those kind of connections.
TomMalufe
07-07-2009, 10:00 PM
Listen to the man when he says it's difficult. Don't think you can make a multi-player game just because you understand how to make a dropdown menu using XML. It's a goodly bit more complicated then that.
Michael_Anthony
07-07-2009, 10:02 PM
Yes it's very possible. here are some resources to get started:
http://www.actionscript.org/resources/articles/871/1/Creating-multi-player-game---TicTacToe/Page1.html
http://www.actionscript.org/resources/articles/881/1/Andrograde-and-Gamantra-announce-partnership/Page1.html
Thanks, I'll check those out!
Michael_Anthony
07-07-2009, 10:05 PM
Listen to the man when he says it's difficult. Don't think you can make a multi-player game just because you understand how to make a dropdown menu using XML. It's a goodly bit more complicated then that.
Of course! I wasn't thinking I could just write two lines of code and it'd magically work :)
abeall
07-08-2009, 05:45 AM
You can't connect users to each other in the Flash Player using ip address. Until just recently, you couldn't do peer-to-peer at all. Flash Player 10 implemented a new protocol (RTMFP) which allows peer-to-peer communication between two Flash Player clients, but only after connecting to an Adobe Flash Media Server which initiates the connection between the two clients.
So in short, you have to connect to server. Now with the right technology it's actually very easy:
Flash Media Server (http://www.adobe.com/products/flashmediaserver/), or using a hosted FMS service like Influxis (http://influxis.com), has a very small learning curve as the server-side code is ActionScript. These use the RTMP protocol which allows push and pull from server, native AS object communication between client and server, and streaming media (video, audio, etc.) You can get a free developer version (http://www.adobe.com/go/tryflashmediaserver) which allows 10 users to connect at once.
Once upon a time I think there were hosted FMS services that provided you with the free developer account, so you could get set up making multi-user apps without even downloading anything, but I'm not sure if that offer is still around anywhere. You can try your luck with this list (http://www.flashcomguru.com/articles/hosts.cfm).
There are some open-source RTMP servers as well, most notably Red5 (http://osflash.org/red5). I haven't been too impressed by the looks of any of them, but hey, they're open source. The biggest problem IMO is that the server application model is really gnarly, unlike FMS which uses ActionScript so it's super fun and easy.
There are also many XML Socket servers, both free (Palabre (http://palabre.gavroche.net), Moock's Unity/Union Platform (http://www.unionplatform.com)) and commercial (ElectroServer (http://www.electro-server.com/), SmartFoxServer (http://www.smartfoxserver.com/) -- both with free versions) servers available. These are fairly easy to learn and they allow server push and pull, but they only communicate in plain XML.
Then if you want you can use old fashioned polling, where you send a server request on an interval and the server responds with any updates. With this you can use any normal HTTP server with a server side language (PHP, ASP, etc) and a database to store persistent game info. This might sound lame but it actually works pretty well in many situations and you can get near realtime interaction.
There's also BlazeDS (http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/) which to be honest I haven't looked into so I'm not sure what it is, but it seems to be an open source AMF remoting solution that claims to allow live push from the server via HTTP. Check it out.
HTH
bluemagica
07-08-2009, 01:49 PM
If you want to make a game without learning much, go for nonoba.com api. You can make, and host a multiplayer game very easily....
But if you want to learn, then learn java(its really very similar to as3), cause java contains many inbuilt network packages, which makes creating your own socket server really easy!
On the flash side, learn as3, cause along with the xml-socket from as2, as3 has added support for direct socket interactions, so you will get a more flexible, fast, and stable performance!
This being said, keep in mind, multiplayer programming is something which even advanced programmers have a hard time tackling! So if you plan to learn, you will require a great amount of patience!
Then if you want you can use old fashioned polling, where you send a server request on an interval and the server responds with any updates. With this you can use any normal HTTP server with a server side language (PHP, ASP, etc) and a database to store persistent game info. This might sound lame but it actually works pretty well in many situations and you can get near realtime interaction.
That actually sounds kind of interesting.
How do you think the performance would be compared to Adobe Flash Media Interactive Server?
I need an update-interval of around 500ms, and I also need the server to do a lot of calculations and such.
abeall
07-09-2009, 01:49 AM
Performance compared to Flash Media Server? Well, Flash Media Server will perform a lot better. But that's a bit like comparing a Ferrari to a Volvo. Compared to Ferrari, Volvo is not very inspiring. But if you just want to go to the store, Volvo will get you there.
I believe I've done polling of 250ms before. This was on a fairly fine tuned server cluster with memchache, though. It was a near realtime app, but it wasn't a game. You're not going to get true realtime. And all the server request will create a pretty heavy load on your server, not to mention totally screw up you server logs (you'll have tons of hits!)
I'd say give a shot and see how it goes if you are interested.
Performance compared to Flash Media Server? Well, Flash Media Server will perform a lot better. But that's a bit like comparing a Ferrari to a Volvo. Compared to Ferrari, Volvo is not very inspiring. But if you just want to go to the store, Volvo will get you there.
I believe I've done polling of 250ms before. This was on a fairly fine tuned server cluster with memchache, though. It was a near realtime app, but it wasn't a game. You're not going to get true realtime. And all the server request will create a pretty heavy load on your server, not to mention totally screw up you server logs (you'll have tons of hits!)
I'd say give a shot and see how it goes if you are interested.
Alright, thanks. I think I've decided to go with Flash Media Server then, but it's good to know about the polling option. I'm gonna get started on that and read some tutorials and stuff, if anyone know a good one I'd be happy to know.
...But why Volvo? That's a swedish car =(
justkevin
07-09-2009, 02:24 AM
I think 500ms + server logic will be strained using HTTP polling. What kind of game are thinking of?
As an alternative have you looked at Darkstar? It's an open source Java project specifically designed for building multiplayer games. I haven't implemented a game in it, but I did download the source and build a test project and got a Flash client to talk to it.
Pros:
It's free.
The developer doesn't need to worry about threading.
Java's syntax is very close to AS3.
Cons:
There aren't a lot of big successful MMOs built around it yet to prove its readiness for primetime.
abeall
07-09-2009, 02:29 AM
...But why Volvo? That's a swedish car =(
Wow I didn't realize you were Swedish, meant nothing personal. Like I said Volvo's are fine cars, they're just not super sports cars. :)
I think 500ms + server logic will be strained using HTTP polling. What kind of game are thinking of?
As an alternative have you looked at Darkstar? It's an open source Java project specifically designed for building multiplayer games. I haven't implemented a game in it, but I did download the source and build a test project and got a Flash client to talk to it.
Pros:
It's free.
The developer doesn't need to worry about threading.
Java's syntax is very close to AS3.
Cons:
There aren't a lot of big successful MMOs built around it yet to prove its readiness for primetime.
Thanks a lot for the tip =)
At first I was like "Oh, no.. I finally decided I'd go with Flash Media Server but now I have yet another option to considerate."
I started reading a lot about Project Darkstar, basically every article about the project they have on the page. And I have to say it sounds great.
It sounds like a very serious project and it seems to be developed a lot.
I'm going to download it right now and read example code and tutorials and try to get it to communicate with flash.
Oh, and an MMO is actually what I'm aiming for, I'm curious how it will turn out...
Wow I didn't realize you were Swedish, meant nothing personal. Like I said Volvo's are fine cars, they're just not super sports cars. :)
Heh, to be honest, I'm not too fond of Volvo's. The fuel consumption is too high in my opinion. I prefer Saab(also swedish).
And I prefer Corvette over Ferrari =) Not that I've ever driven any of them.
justkevin, you wouldn't happen to have a working example client would you?
I would really appreciate that.
It's hard to find good information on how to get flash to work with Darkstar, and I don't even know where to get started...
bluemagica
07-09-2009, 09:49 PM
try here:-
http://siddhantt.com/Blog/?p=20
http://siddhantt.com/Blog/?p=27
this is a two part tutorial to get ds working with flash!
try here:-
http://siddhantt.com/Blog/?p=20
http://siddhantt.com/Blog/?p=27
this is a two part tutorial to get ds working with flash!
Thanks, found It yesterday and I worked on it like all night but then got stuck, finally figured it out though.
Hopefully I can get it to work...
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.