PHP Gaming: Part 3
Since this is part 3 it'd probably be best if you are already familiar with the concepts
used in part 1 and 2:
Part 1
Part 2
Now, to begin, the main aspects we will be covering in this section regard using your
ticks/turns or whatever units you wish to use in your game, and going hand in hand with
that, production of resources, units, etc.
First off, you'll need to decide on your unit of time or currency basically. I personally
use Ticks and turns. You can choose one of those, or make up your own. It's basically all
the same thing in the end.
Next, you need to decide if your item will be used as Time or Currency. For my own game I
wanted to be able to have units for time and currency, (ticks and turns). The difference
between the two is if it can be spent, or if it is naturally occuring.
For the following part, I'm going to pretend we're making a game using ticks that happen
hourly and run a production cycle, so if you are using a unit of Time read this part,
otherwise continue on to the next section.
Time
First of all, what we want to do is create a file that will be accessed just by the server
through Cron Jobs. You can choose to either have that file in a non-public folder, or in a
public folder chmodded to '700'. For this tutorial we're going to have a file "tick.php" in
an non-public folder.
Next you'll want to set-up a cron to run that file hourly, however rather than tell you how
that's done, here's a link to Tim's tutorial on PHP and Cron:

| Hits: | 197 | Last Updated: | 2006-07-08 |
VIEW ALL
PHP Tutorials