SitePoint Sponsor |
|
User Tag List
Results 1 to 23 of 23
Thread: PHP for online game development
-
Dec 17, 2003, 03:34 #1
PHP for online game development
Hello,
Where I can find more information/articles about PHP that focused on online game development? I mean the game like those listed in www.mpogd.com
Thanks
-
Dec 17, 2003, 04:26 #2
- Join Date
- Apr 2003
- Location
- Germany
- Posts
- 151
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, you can draw inspiration from existing games, like the one you listed.
In my opinion one has to put alot of thought into such a game, it isn't really easy.
(Ok, that didn't really answer your question)
-
Dec 19, 2003, 03:34 #3
-
Aug 31, 2004, 09:24 #4
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Another question:
Could anybody tell me, what languages I should use?
PHP, SQL - thatīs clear and no Problem.
But what about the realtime solution?
I create a car / ship / whatever I need to create in my game, and it takes 30 minutes to finish it.
I can countdown in HTML and JavaScript, but when does my DB know, that the user has got one more car / ship whatever?
Should I create a Java Server and manage the backend like that?
Or how could I do this?
Thank you
Bye, Transmitter
-
Sep 22, 2004, 13:36 #5
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Isnīt there anyone, who knows a bit more of it?
-
Sep 22, 2004, 20:03 #6
- Join Date
- Aug 2003
- Location
- Melbourne, Australia
- Posts
- 454
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
With all due respect, I do not think it is feasible to create games like you described above (highly interactive, multiplayer and timeline based) in PHP/js/html.
-
Sep 22, 2004, 20:12 #7
- Join Date
- Aug 2004
- Location
- California
- Posts
- 267
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I had been interested in creating a text based game for quite some time.
Just learn how to use cron jobs and you shouldn't have a problem with "events" that occur at certain times of the day, or every hour, for example.
-
Sep 22, 2004, 23:51 #8
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Aska: What do you think, I should use?
Iīve looked at some online games, and they are implemented with PHP / MySQL / HTML / JavaScript and one CroneJob per Day to update the ranking list.
thirteenlisk: But this isnīt a job for Cron, is it?
Lets say, a user clicks on a "build a ship / car / whatever", what happens next?
Do you activate your CronJob, wich knows the time, user, building, and so on, and after the building time, the CronJob gets executed?
Lets say, you have 3000 players online, everyone builds 1 building, 1 car, 1 fighter and researches a technologie .. 4 CronJobs per User, 3000 Users, so you have 12000 CronJobs to be executed the next few hours.
Is this the way to got?
I canīt imagine that
-
Sep 23, 2004, 00:13 #9
- Join Date
- Sep 2004
- Location
- Lithuania
- Posts
- 10
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
All those text based online games are driven by turns. Turn is basically executed every hour by some cronjob. This turn involves all kinds of data calculations/database updates. So when your player orders to build a ship/car/whatever you should add his request somewhere and this request will get processed by your turn script. Although, some actions such as sending messages should be real-time based.
-
Sep 23, 2004, 00:22 #10
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So you have a 'TempTable' where you store the users activities, like build a ship.
Lets say the user has got 0 ships and one ship takes 10 minutes to create and he told the system to create 2 ships ( = 20 minutes ) ..
After one hour ( worst case ) my CronJob updates everything from the temp table to the user table, and in the meantime of 40 minutes, the user hasnīt got his ships, although the were ready, 40 minutes ago?
-
Sep 23, 2004, 00:28 #11
- Join Date
- Aug 2003
- Location
- Melbourne, Australia
- Posts
- 454
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Transmitter
-
Sep 23, 2004, 00:36 #12
- Join Date
- Aug 2004
- Location
- California
- Posts
- 1,672
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I don't think you need cron to do what you are talking about, just a great database design. You should focus more on reducing the amount of data that needs to be pulled from the database to build a screen. You can add objects to the game world all you want. The trick is only fetching the objects near to the player, and only re-fetching as necessary. It sounds almost like a tiler.
-
Sep 23, 2004, 01:59 #13
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by arborint
Code:// overview.php: $user = getUser ( $id ); $buildings = listBuildings ( $user ); if ( $user->inTempTable ( ) ) { // check actual time and finishTime // if ( finishTime < actualTime ) // update UserTable FROM TempUserTable; } // User klicks on building, e.g. mainhouse, actual level: 3, a klick expands the // mainhouse to level 4 within 2:34 hours // action.php $user = getUser ( $id ); // or from session, or what else $user->buildMainHouse ( ); $template->showRemainingTime ( ); // user.class.php: function buildMainHouse ( ) { insert userID, actualLevel, finishTime into TempUserTable; }
With the if ( $user->inTempTable ( ) ) in overview.php I substitute a CronJob, am I right?
-
Sep 23, 2004, 06:20 #14
- Join Date
- Nov 2002
- Posts
- 194
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm working on a game like this right now. One possible solution would be when you build a ship that takes 30 minutes to build, just calculate a timestamp based on current time + 30 minutes and add that to the database record for the ship. Then you can calculate whether the ship is finished building and ready to use or whether it's not done yet.
-
Sep 23, 2004, 10:24 #15
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Is there a solution, wich doesnīt cost so much DB traffic?
With every page reload, you have to check many things against the db .. is there another possible solution, or is Java or another backend the only thing you can think of, without stressing the db such often?
-
Sep 23, 2004, 11:51 #16
- Join Date
- Jun 2004
- Location
- Northeastern Ohio
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If I were to do an online turn-based game nowadays I would use PHP, and if I needed more backend performance I'd compile shmop into PHP to add memory-based persistence, and if that weren't an option I'd switch to a Java solution such as orionserver or resin.
First, you should develop a prototype in a scripting language, in this case it would be PHP, but feel free to swap PHP with Ruby or Python at any time. Why a scripting language for a prototype? Ease. You can quickly whip up classes relating to the data you're handling. Who cares about speed at first. You need to get the system down first before you worry about optimizing stuff.
If you get to a point in your programming where you feel you need some sort of memory-based persistence, make the switch to shmop or Java. But since this is turn-based, directly accessing the database for all persistence should suffice.feti
Mojavi Project - Mojavi 3.0.0-dev available now!
-
Sep 23, 2004, 12:16 #17
- Join Date
- Oct 2003
- Location
- Germany
- Posts
- 90
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Nice to see you here
But, could use Ruby / Python with your nearly perfect product?
But Iīll consider shmop, or Java if shmop doesnīt fit to my needs.
Thank you feti, for your excellent overview and thank you all for your help
-
Sep 23, 2004, 15:03 #18
- Join Date
- Aug 2004
- Location
- California
- Posts
- 267
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by simast
PHP/MySQL/JS/HTML with a cron job at certain times of the day is what drives most online text based games today, and should be able to handle pretty much anything you throw at it.
-
Jan 10, 2005, 07:03 #19
- Join Date
- Nov 2001
- Location
- Melbourne, Australia
- Posts
- 3
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Just wondering if anyone would know what sort of minimum specs and cost to run a web-based game server?
< Axolotl >
-
Jan 10, 2005, 07:24 #20
- Join Date
- Dec 2004
- Location
- Bristol, UK
- Posts
- 259
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Very little if no-one plays it
Seriously though - at the end of the day that is exactly how you will calculate your costs. Number of active players X the resources each player uses in a typical session. All factors depend utterly on the game you've coded of course - only you can answer that question.
-
Mar 13, 2005, 12:43 #21
- Join Date
- Jun 2004
- Location
- Milwaukee, WI
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hello,
I couldn't help not to reply to this question. Some of you are saying use CronJobs, but no! CronJobs are not the way to go. You use JavaScript/HTML as your front-end (build stuff, etc) and PHP/MySQL as your back-end (submit stuff to your db, like who built what).
I have been practice making PHP/MySQL/JavaScript/HTML games for awhile now.
Hope that helps.
-
Mar 24, 2005, 23:25 #22
- Join Date
- Nov 2004
- Location
- Melbourne, Australia
- Posts
- 167
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
php-gaming.org is decent.
-
Jun 27, 2005, 00:29 #23
Thanks for the links. This is actually what i'm looking for. I'm surprised that someone reply to my old topic
Bookmarks