steps to make browser game

some hints how hard can it get

Page 1 of 1

3 Replies - 3562 Views - Last Post: 16 April 2008 - 03:10 PM Rate Topic: -----

#1 2457   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 09-April 08

steps to make browser game

Post icon  Posted 14 April 2008 - 10:22 PM

I made this post, to show those who are intrested how much work is involved in makeing a php + mysql + java game.Since I saw a lot of post about how people start off, this topic will give some hints..
You have to know that I myself is a "sunday programmer" I don't know too much of programming, but to realise how hard is it, I know enough.
//PS I'm not english, so sorry for the typos..

First thing is first, makeing a game without knowing a decent language is not possible. Realy.
BUT learning a language while making a game seems possible.
It all depends. I needed to make some webpage processing a small database, thats why I was looking to server side scripting.

What I saw:
PHP is something, what in my opinion is the holly grail. In a week or so, I got registration page, data upload to a mysql database, and made the database searchable by users, and output form is PDF. I'm stoned how easy it is. So.. Lets see what php has to offer, and why I chose this language :

1. is free, many free hosts offer it (great!)
2. interaction whit mysql is a piece of cake
3. verry easy to learn, and understand

So, for creating Yours first game, I would advise to use thisone.
I'm not a great coder or something, but php can be learned for free online, and have a community wich is realy helpful.


So much for the basic language.


As I noticed, most people upto makeing a game have a basic concept.
Well, a concept is needed, but is not the most essential thing to have.

What You need to start, is a notebook.
First, before any coding a browsergame You need to specify what You want Your users be able to do.
Well, I was thinking of makeing a game too, so I started listing all the features I would need to implent. Thats a good start.
Then I made the mistake to start coding. Bad idea. I wanted to code every single thing into one big .php file. I tell You, i think it is not possible..
Even if it was, it is a not a good choice. Sometimes You have to modify a few things, searching a BIG file is HARD...
Other problem is, first thing rght after listing the features, is to create the database for them.

I will update this post from time to time, I re-started with my little game.
Even if I never finish it, it will still show what effort it takes to make a realy simple game.

The database is the soul of things, or may I say the skeleton.
every single thing, every attribute, every player, anything is stored in the database, so makeing a good database is rather hard.
To be able to adjust settings of the game (for example the hit point of a unit) I would make an xml file to hold them. PHP can acces it easyli, so can You.

So, after listing what Your game has to offer, and makeing the database,
You can start to code stuf.

Now, the concept of a browser game is, that people do something, and in exchange they get some feedback.

Sounds easy, but is NOT.
If anything happens in Your "world" then it has to be writen into the database. Some things happen immidiatly, some may need time.
(for example, sending Your hero to train a skill ay need X hours)
So, You have to search how to achieve thatone.
there will be scripts that are launched in a given time, and scripts that just query the database to show Your player "the current state".

So we have 3 big portions of the game.
1 is the database
2 is the script that shows current tate (level of hero, or population of a town, or.. resources available at the time of the query)
3 scripts that will be launched even when the user is not online (like.. every hour the mines give x resource, or moving the troops finsih then, and so on)

So, You have Your concept of the game, You know what Your users be able to do, You have Your database, so whats the next stepp?

OFF COURSE, the scripts running on the server!
Like adding resources every x minutes, based on the level of mines.
That is the point where things get a hard.
You will haveto make 2 groups of these, a group that does nto need any user input (like the resource adding, level of mines can be retrieved from the database, and adding resources based on that level and updateing the database), and an other group wich needs user input. (like sending 50 tanks to attack someone.. it takes time, so from the start of the user input + x minutes to get there, meanwhile sending a report to the defender, when the units get there calculate the "battle", send feedback report to attacker and defender, and have some sorth of option for the attacker to monitor troops movments and so on...)

I would start with the ones that does not need user input.
It helps to get in shape, and to learn programming.

When makeing the feature list, be sure to write what steps are needed to be done to "achieve" that feature.
Like.. sending a mail to other player.
This would involve to:
have a html form, where the recipent can be specifyd, and a field for the messege. Be sure to check if both had been filled, see if the recipent exsist (query database) what happens if user does not exsist, or the messege body is empty, then send the messege.
Now.. sending it is equal to put it in the database, and create a flag to inform the recipent (like diplaying an envelope) that he/she has a new mail. and when the recipent opens the mail, hide the envelope.


Now comes the trick. This all may be made in one large script, but it would not be preferd. Checking if user exsist for example can come handy later (like when attacking someone, it should be checked too) so makeing a small script that can search for the user is more like something to do. So whenever next time You need to see if a user exsist or not, You can call this small script, and see if it returns to true, or false.

Notice, this is just a verry small thing, and how much thinking it takes...
My advice would be, to make scripts as small as possible, and keep the DOCUMENTATION of wich script does what. If You made a mistake that needs to be corrected (searching for a user, is case sensitive or not? for example) it will be much more easyer. If You would had made larger scripts, and many many script would contain the same code, each one would have to be correted. This way only one short code needs a bit of work. That is cute.

Welll,,, for now thats all.
The post is made, becouse I noticed there are some real smart guys/girls here, I would like to hear their opinion on the topic so far.
If I manage to keep this alive, and achieve a good understanding of things, I hope I will be able to make a post that will be sticked up as an "importent" post, showing some guide for begginer browser game creators.

So, to start, I would recommend PHP, becouse its easy and free, and to make it more easyer, I would allso recommend Komodo Edit .
That little program is AWESOME, it helps a lot.
Search for... any free host to experiment Your skillZ with PHP and mysql,
then You are ready to make the first bits of code.
http://www.php.net/ is a good place to learn, it has PHP functions well documented, and has verry good examples too.

Is This A Good Question/Topic? 0
  • +

Replies To: steps to make browser game

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6642
  • View blog
  • Posts: 30,931
  • Joined: 10-May 07

Re: steps to make browser game

Posted 14 April 2008 - 10:25 PM

View Post2457, on 15 Apr, 2008 - 01:22 AM, said:

http://www.php.net/ is a good place to learn, it has PHP functions well documented, and has verry good examples too.

Plus, we have a bunch of great Tutorials & Code Snippets for PHP here, as well.
Was This Post Helpful? 0
  • +
  • -

#3 2457   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 09-April 08

Re: steps to make browser game

Posted 15 April 2008 - 01:26 PM

in most examples, and not just for PHP, You will see variables like..
$a and $b and so on.

Don't do this.
It is a suicide.

As I all ready had advised, break down the code into small usefull short scripts. So You can recycle them anywhere needed. Saves time and prevents headaches.

So, the next thing is nameing the variables.
Short names made of 1-2 letter and maybe a number do not tell anything about the variable itself.
in PHP You can use the _ in the name of variables, for example.
It looks pretty much not-so good to have long variable names, but it helps a lot, so useing them is good. Like... You made a small script to calculate the outcome of an attack, and it is in a separate file, and You include it.

Let it be "battle.php".
Variables used in this script should be named like:
$battle_attacker_hp
$battle_attacker_dmg
$battle_defender_hp
$battle_defender_armor

So if You include "battle.php" inside an other PHP file, You won't have variables with the same name, debugging something like that is painfull work, if they happen to couse problems. Allso if You need to re-adjust the attack script, the name of the variables will be like a documentation of the data they hold. Easy to make changes, if You know which variable is exatly what.
Was This Post Helpful? 0
  • +
  • -

#4 2457   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 09-April 08

Re: steps to make browser game

Posted 16 April 2008 - 03:10 PM

about comments.
Most of my time I started learning PHP and copyd snipets and manipulated them to see how things work, I did a cooment on almost every secund line.

Well, it made the files BIG, and short after that I have found that too many comments halpas much as none.

Commnet Your scripts, it helps a lot, but use only the minimum.
Make it informative, it is not a blog, but a comment to help You remember what the script or a part of it does. No need for anything else.


Allso.. if You have a lot of files, You will surely loose track of what they do exactly.
My noobish technique to overcome this, is nothing more tan a plain XML file.
I use COMODO EDIT, it has quite nice xml support.
If You write Your little scripts that You tned to use on the way, add it to an XML file with proper description of what it does. Comodo will show the XML file like a menu. So You can organize Your little codes, and have detailed instruction how to make them work. (input -> output).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1