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
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.