Entire game in one page?

C++, C#, Java, PHP, ect...
User avatar
MAruz
Posts: 117
Joined: Fri Nov 20, 2009 12:31 pm

Entire game in one page?

Post 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?
PHP, Java, JavaScript, HTML, CSS, XML, MySQL / Oracle
Photoshop, Illustrator
www.cuddly-zombie.com
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Entire game in one page?

Post 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.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Entire game in one page?

Post by hallsofvallhalla »

yep, just using includes and get/post statements. I have started doing that also.
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: Entire game in one page?

Post by ZeroComp »

I really dislike ogame a lot. I hate just the overall playing style :evil:
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Entire game in one page?

Post 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.
The indelible lord of tl;dr
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Entire game in one page?

Post 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.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Entire game in one page?

Post 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.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Entire game in one page?

Post 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 :)
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Entire game in one page?

Post 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.
The indelible lord of tl;dr
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Entire game in one page?

Post 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.
Fighting for peace is declaring war on war. If you want peace be peaceful.
Post Reply

Return to “Coding”