Page 1 of 1
Multiplayer game
Posted: Fri Mar 25, 2011 4:30 am
by terumi
Hello everyone.
After watching the tutorials named "Browser Based MMORPG" I realized that the subject of making the game actually multiplayer wasn't covered.
I'm trying to build a simple dueling game, and I want to have two (or more) players logging in an "arena" in order to fight.
The game, I reckon, has to be turn based but I cannot find a solution about giving each player the oportunity to know whos turn is.
So my questions are:
-Is there an event system in php?
-Is such thing as shared session variable?
-Is it possible to do a "whos turn is" check without some cron job or a loop that checks if the players turn is finished?
-Is it a tutorial about the multiplayer subject?
Thank you very much.
Terumi.
Re: Multiplayer game
Posted: Fri Mar 25, 2011 11:04 am
by hallsofvallhalla
-Is there an event system in php?
if you write one yes.
-Is such thing as shared session variable?
not really unless you store the variable in the database and then check it on page load or you use Ajax.
-Is it possible to do a "whos turn is" check without some cron job or a loop that checks if the players turn is finished?
this would require ajax or a page refresh
-Is it a tutorial about the multiplayer subject?
yes, while i have not added true multi-player or PVP it is quite simple to make it happen. The game in itself is mult-player just not so interactive. I am working on tutorials to make it so .
Re: Multiplayer game
Posted: Fri Mar 25, 2011 4:27 pm
by terumi
First of all thank you for your time to respond, make all these tutorials, interact will all us...
-Is it possible to do a "whos turn is" check without some cron job or a loop that checks if the players turn is finished?
this would require ajax or a page refresh
Should the ajax performing a loop to check the states or is there a more "elegant" way of doing it?
Thank you again.
Re: Multiplayer game
Posted: Fri Mar 25, 2011 5:55 pm
by Jackolantern
It depends on what you want it to do. The more real-time you want it to be, the more you will have to rely on short-timered AJAX loops (aka "polling") to check for changes. However, this has many downsides, such as the amount of wasted server CPU power and bandwidth. There are some other, more advanced options such as Comet, web sockets or an RIA platform, but those both require dedicated server software outside of the web server software.
Re: Multiplayer game [SOLVED]
Posted: Sat Mar 26, 2011 3:15 am
by terumi
I used polling to check if a text file (containing a single status code) has changed.
As the game is a turn based game, I hope that the bandwidth consumption is minimal.
Thank you for your insights.

Re: Multiplayer game
Posted: Sat Mar 26, 2011 3:24 am
by Jackolantern
It just takes some tweaking. You want to find that sweet spot where you are waiting as long as you possibly can in each polling cycle. Just an extra half a second can mean huge bandwidth savings if your site becomes popular.
Re: Multiplayer game
Posted: Sat Mar 26, 2011 1:19 pm
by terumi
Nah.. I'm into learning rather that being a succesfull/ rich/ popular game designer.

Re: Multiplayer game
Posted: Sat Mar 26, 2011 3:44 pm
by PaxBritannia
I can't express how much I adore the sentiment you just conveyed.
pax.
Re: Multiplayer game
Posted: Sat Mar 26, 2011 6:10 pm
by Jackolantern
Even if you don't make any money, eventually it is nice to have something you make become semi-popular to keep you moving forward. Ask Halls about that
EDIT: Plus, writing web software for popularity (aka "scalability") is just considered good practice, since your creations will break after they receive so much traffic at once if they are not. Regardless of what you are developing for, it is always a good idea to build your applications to be as robust as possible.
Re: Multiplayer game
Posted: Sat Mar 26, 2011 10:28 pm
by Callan S.
Yeah, it depends on what your trying to learn. I'd say the most common practices are those which optimise like Jack says - so if your trying to learn the common practice, that's what you'd be learning, even if you never need it.