Page 1 of 2

Entire game in one page?

Posted: Sun Jan 17, 2010 11:21 pm
by MAruz
I've been looking into a few browser games lately, and found this one: http://ogame.org/
I noticed in the url that it always says index.php and then pass variables in the url that handles what content should be shown now (page=overview or page=battle etc). The page never refreshes (lots of js / ajax work).

Anyone ever done this before? Is it worth the effort rather than sectioning up the game into different pages?

Re: Entire game in one page?

Posted: Sun Jan 17, 2010 11:27 pm
by OldRod
I've seen a couple others that way too - they are most likely parsing the URL in index.php and then "including" other php files as needed to process it.

Re: Entire game in one page?

Posted: Sun Jan 17, 2010 11:58 pm
by hallsofvallhalla
yep, just using includes and get/post statements. I have started doing that also.

Re: Entire game in one page?

Posted: Mon Jan 18, 2010 12:35 am
by ZeroComp
I really dislike ogame a lot. I hate just the overall playing style :evil:

Re: Entire game in one page?

Posted: Mon Jan 18, 2010 4:34 am
by Jackolantern
The one of the benefit from using a one-page technique is that the game will not get messed-up by players moving around from page to page.

Re: Entire game in one page?

Posted: Mon Jan 18, 2010 10:33 am
by Chris
If you were to put it on one page, your file would get so big it will reduce loading time. It would be better to use seperate files.

Re: Entire game in one page?

Posted: Mon Jan 18, 2010 1:22 pm
by OldRod
Chris wrote:If you were to put it on one page, your file would get so big it will reduce loading time. It would be better to use seperate files.
Not if all that page did was a huge switch{} and only included other stuff as needed.

I'm doing pretty much everything in my index.php file right now and it's nowhere near the biggest php file in my game so far.

Re: Entire game in one page?

Posted: Mon Jan 18, 2010 2:29 pm
by hallsofvallhalla
but remember that php reads the entire page anyways.

with that said I have a combat page that is 2000 lines and I see no difference in it and a 100 line page when loading. I haven't tested this with 100 people trying to load it though :)

Re: Entire game in one page?

Posted: Mon Jan 18, 2010 3:31 pm
by Jackolantern
Exactly. People talk about the speed issues of PHP, but we are not talking about 1980s computing speeds. The difference between a 200 line script and a 2000 line script is negligible. Also, the single page technique is not made with huge switch statements, but rather, it stores where the player is in the database, and then simply loads in everything about that location.

Re: Entire game in one page?

Posted: Mon Jan 18, 2010 4:33 pm
by Chris
If you are planning to make a game that will actually do well, where a page will be loaded atleast 5000 times a day. Now calcualate how much bandwidth will be eaten when including two scripts that are only 4kb or constantly loading a file which is 50-60kb.