3 Replies - 5009 Views - Last Post: 07 June 2011 - 06:53 AM

#1 puyunk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 27-April 11

How to connect 2 or more laptop to play flash games?

Posted 01 June 2011 - 09:23 PM

Hi all,
following my thread before which in here, I want to ask some questions.

Now, the thing is, I am finally choosing flash quiz game to make, and I almost finished with it. The thing is, the teacher want me to upgrade the game. Here is the scenario.

My laptop will play the games (flash), and some other laptop will play it too. Now, my laptop will be able to play and watch.

My question is how to connect each laptop so that we can play together?

Thank you for the reply and good day. :D


Is This A Good Question/Topic? 0
  • +

Replies To: How to connect 2 or more laptop to play flash games?

#2 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2538
  • View blog
  • Posts: 4,641
  • Joined: 24-September 10

Re: How to connect 2 or more laptop to play flash games?

Posted 03 June 2011 - 07:14 AM

Well with flash there are a couple ways to do it. Here's a few.

Direct-Connect:
you can make a direct socket connection between the 2 computers. This doesn't have huge room to grow and requires each player to know the address of the other players (generally IP address). I suggest against it.

Client-Hosted:
one player acts as a host and all the other players make a direct connection to them. Similar to direct-connect, but in this case every player only needs to know the host. This is how a lot of multi-player games do it on a home network (think like Unreal Tournament and Warcraft3/Dota that you may play with 4 of your buddies at a LAN party).

Client-Server:
Have a non-competing machine act as server who every player logs into. It usually doesn't have the actual game and instead has a slimmed 'server' version that only handles mitigating the game between all players. This is the model most games are moving to now a days because the Client-Hosted method tends to grant an edge to the host. This method on the other hand gives the edge to a non-playing party, edge only being giving to members who have better connections (and some servers have algorithms to throttle connections to bring down fast connections to a level playing field). This is how most console games do it, and even PC games like Minecraft and those who play on the Steam server (as opposed to 'local-hosted' which is 'Client-Hosted').



Of course the Client-Server model is the most dynamic and extensible. But it also is the most complicated method. The server couldn't be written in Flash and would instead have to be in whatever language you decided to write the server in (AIR, the system level flash, is actually an option... though probably not the best). Of course for online games it's usually the defacto method to use it in some degree (remember the server is still a server if all it does is handle sharing the addresses of each player), how else would you get 2+ players together easily and with out having to explicitly have each player type in some IP address and open up ports and really have to configure the heck out of stuff.

The other methods are a little easier on the developer and can all be done right in flash. It'll be slower and more cumbersome for each player to connect with each-other.

There are of course even more methods, but most of them are either dated or just not possible with Flash.



With proper design you can actually write the game to support all methods with a Facade interface. Your game would never actually directly deal with the networking and would instead deal with some object model that represented multi-player functionality and a 'global-state' that represents the game across all players (which would even enable multiplayer on one machine). Then the object that deals with communication would just be a facade that wrapped around all possible connection types... it would only use the one it's supposed, set up in configuration.

This gets into more advanced design patterns though, and isn't really an answer to your initial question.

This post has been edited by lordofduct: 03 June 2011 - 07:19 AM

Was This Post Helpful? 3
  • +
  • -

#3 puyunk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 27-April 11

Re: How to connect 2 or more laptop to play flash games?

Posted 06 June 2011 - 11:25 PM

Hi lordofduct, thanks for the reply.

I actually kinda like the idea of making one machine (laptop) to be the host and the other player will connect to that laptop to play.

But, I am really confused in how to create that kind of connection. Do you know any tutorial that tell me how to begin on? I never really play games like Dota before, so its kinda confused me now. :D

Thanks in advance. Good day.

This post has been edited by puyunk: 06 June 2011 - 11:26 PM

Was This Post Helpful? 0
  • +
  • -

#4 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2538
  • View blog
  • Posts: 4,641
  • Joined: 24-September 10

Re: How to connect 2 or more laptop to play flash games?

Posted 07 June 2011 - 06:53 AM

Well if you want to go the 'client-hosted' method where the actual Flash game itself acts as a localized server, then you're going to first make sure you're developing in the latest version of Flash/Actionscript and probably should be using AIR. You can then have access to ServerSocket which makes accepting TCP connections pretty easy:

http://help.adobe.co...rverSocket.html

There's not as many tutorials out there using this method though as it's fairly new (I think Flash CS4 it was taken out of beta, not sure exactly off the top of my head).



What you could do is google around about creating a Java based socket server for flash games, then just pull the java design into Flash/AIR (which would require some tweaking). It's not simple stuff though and you shouldn't be going in blind. You should go out and probably research how exactly game networking is done on a theory side (tutorials are good, but you should have some theory under your belt as well to help in making the tutorial more understandable).

This post has been edited by lordofduct: 07 June 2011 - 06:54 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1