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?
Entire game in one page?
Re: Entire game in one page?
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.
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Entire game in one page?
yep, just using includes and get/post statements. I have started doing that also.
Re: Entire game in one page?
I really dislike ogame a lot. I hate just the overall playing style 
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Entire game in one page?
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
Re: Entire game in one page?
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.
Re: Entire game in one page?
Not if all that page did was a huge switch{} and only included other stuff as needed.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.
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.
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Entire game in one page?
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
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
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Entire game in one page?
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
Re: Entire game in one page?
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.