PDA

View Full Version : PHP Gaming: Part 1


Darkneo
05-19-2008, 12:27 AM
Originally Posted By Shwaza

I've decided to start off an entire "series" of php gaming tutorials. So expect there to be much more to come after this. I find running my game really fun, and i know my members enjoy playing it


For this part, we aren't going to even begin talking about the PHP of the game. The very first thing that you need to do if you are making a game, is structure it. A game that is very well coded, can be a lousy peice of ... if you don't have a good structure for it. I'm now going to take you through a few steps to get you started with your structure.

PART 1: Resources

First and formost, we need to get a list of resources, for your game. These could include anything such as Money, Food, Metal, etc. You need to have something to spend in your game. (also, i'll be talking about turns, and/or ticks later on).

Please make sure that you have gotten a full list of resources for your game, before we continue.

PART 1b: Resource usage

For this part, we're going to assume that our game has 4 resources: money, food, wood, and metal.

What you need to do, is figure out what your resources will do. It's all well and good if you have a bunch of resources, but it's completely useless if they don't do anything!

We're now going to make a list of what resources will be used for. Just as an example, here's what your list might look like:

Money: Building, researching, purchasing
Food: Keeping units alive, building
Wood: Building
Metal: Building, purchasing

Now, do something similar to that, but with your list of resources, and wait until you are done that, to continue on with this tutorial.

Part 2: Units/Buildings

Most games that you will play, have units, and or structures, such as troops, and barracks.

What we're going to do now, is make a list of all the different units and buildings we will be using.

For an example, here's a list of what you might have:

Light Troops
Heavy Troops
Houses
Barracks

It's a rather short list, and hopefully you'll have more in your list , but it's just to give you an idea.

Part 2b: Troops/Buildings creation

Since you've got that nice list of units or buildings, and that nice list of resources, we're going to combine the two, to give a purpose to the resources, and a way to obtain the units.

As before, we're going to make a list, and set it up like this:

Light Troops: 20 money + available housing
Heavy Troops: 50 money + available housing
Houses: 50 metal + 25 wood + 50 money
Barracks: 100 metal + 50 wood + 100 money

Now, you'll see that for the 2 types of troops, i also included "Available housing". If you are trying to make a realistic game, you will most likely want to give your units a place to live! So you should decide on a good amount that each house, or barrack can hold, then, in your script, you would add an if/else statement, to check if there is available space for your units.

So after you've made that list, continue on to part 3.

Part 3: Researching

Usually, games will have something like researching, production, or something like that. What you would have, is research, that will increase your production of units, and resources, so that every time you use a turn, or a tick occurs, you will recieve x amount of resources, and units.

For an example, i'm going to say that each research costs 100 money (you might want to give each kind of research it's own value, or possibly a dynamic value, like $price="$units / 100"; or something like that), per purchased.

So if you think you've got a good idea on how you're going to set this up, continue on to part 4!

Part 4: Turns? Or Ticks?

Well most likely 99% of all online strategy games rely on turns or ticks to run. What you have to decide, is which one will you use? Or both? I personally use both, because i thought it would be an interesting twist, however i declare the copywright on that! Haha, just kidding.

After you have made your descision, you have to decide what you want to do with them. This is mostly if you decide to use turns, because you have to decide if you will have players spend them to buy/create things, or if you want them to be something you do manually, and when you cash one in, it adds your resources via your production rate, to your total. I find that turns are most commonly used as a resource, and are spent, but the choice is yours! It's your game!


This is the end of the first tutorial on php gaming. By now, you should have a pretty good idea of what the structure of your game will be like, and you should be able to start coding it. That will be comming in the next tutorial, so stay tuned!

Thanks for your time, and please post your comments or questions here!

Also, if this has been helpful or interesting to you, i'd appreciate a little bit of reputation Sorry to have to say that, i just find people aren't giving it out as much.

Have fun! Also, if you'd like to take a look at my game, i'm more than happy to get new players! http://kingdomsofbattle.com