Showing posts with label start. Show all posts
Showing posts with label start. Show all posts

Thursday, September 13, 2007

Starting Basic Strategy game

I have chosen to pick Action/Strategy as genre for our next game.
So basic ideas:

  • player has money (he gains it every hour - from his registration time)
  • he can train units (1 different type), and this unit can be equipped with weapon (1 out of 3)
  • he can build defensive or economical structures (to get more defense or gain more money)
  • he can attack others and steal their money
How to start?
We need database with 1 table. Structure will be like this:
ID / username / password (protect it, if nothing else then md5) / email
also we must add other things, so it would look like that:
ID / username / password / email / lastupdate / money / units / weapon1 / weapon2 / weapon3 / wall / bank

Do not forget to optimize table and set money, units, weapon1-3, wall, bank to 0 as default!
Lets say this table is called 'users' so we connect to it using config.php and selecting user that is logged in (SELECT * FROM users WHERE password='$password' AND username='$username'). We use php function to fetch this row:
$user = mysql_fetch_array($selection);
to use any thing from our logged user we can use $user[X], where X is thing we like to use. For example if we want to see how much money does logged user has, we use:
echo "Logged user has: ".$user[money]." money".
Also you must create login and registration system* (in registration when adding new user do not forget to add $time_now ($time_now = time();) variable to lastupdate column!

So lets create main page (main.php), where we will show user information:
<?
echo "Username: $user[username]<br>
E-mail: $user[email]<br>
Money: $user[money]<br>
Units: $user[units]<br>
Number of Weapon 1: $user[weapon1]<br>
Number of Weapon 2: $user[weapon2]<br>
Number of Weapon 3: $user[weapon3]<br>
Wall level: $user[wall]<br>
Bank level: $user[level]<br>";
?>

This is all we need to start our basic game.
In next post I will explain how to make that money updates automatically every hour.

*You can find tutorials on login/register system on several tutorial sites.

Start is Hard

Starting is always hard.
Not enough ideas, not good plan, voices in your head (like: why am I doing it?!)... but hey let's just start!

Warning!
This blog is not going to be like all blogs which like to be only theoretical about PHP games.
But this post is :)

Browser based games can be divided in next genres:

  1. Strategy
  2. Action
  3. RPG
  4. Sports
  5. Business
So when you have decided about genre you need to make GOOD plan for your game. Coding is easy with good plan and good economy. But how to achieve that?
  1. Try to write down everything about your future game (in short form)
  2. Create Game Design Document (where you explain all mechanism of your game)
  3. USE Excel (MS or Open ones...it does not matter), to produce your starting economy (will explain this more later)
This is all you need BEFORE you even start coding ... if you want to produce decent game.
So more about economy; it depends on what game are you making, but basically it goes like this:
  • try to write all prices down and all items (if any)
  • make and test formulas you would use, and compare different versions
  • use graphs to see your work
  • try to make everything connected (so if you change one price, then everything connected to this value changes - so you do not need to fix several things)
Now we have prepared all we need and coding can start.