How to write a php online game similar to Travian?

How to write a php online game similar to Travian? What is required is knowledge of programming? How the programmed events in the game?

Wouldn’t a game be written in Actionscript (ie Flash)?

well but hattrick (I know it is written in asp.net)??

edit: Travian is written in php?

I registered so I could see how it worked.
The visuals would be handle with html and javascript
A database would track your information
PHP would connect the two and run processes as needed.

Hey Derpost,

You can build a browser-based game using the following:

  1. You’ll need a nice design
  2. HTML, CSS & JavaScript for the UI
  3. PHP to handle logic
  4. MySQL to store data

If you don’t have sufficient knowledge in any of the above and you’re planning on building it yourself, it’s going to be a while before it’s possible as you’ll have a lot to learn. On the bright side, if you’re learning this to build something you’re really interested in you’ll enjoy it, don’t get me wrong… you’ll still be pulling your hair out now and then just like the rest of us :slight_smile: , but you’ll be motivated to keep going.

Best of luck and keep coming back here anytime you need help :slight_smile:

You can’t really build a game in just PHP. (If it was that easy, I’d do it :P) You will want something like Flash/ActionScript, Java, or simply JavaScript if you’re good. PHP could just be handlers for the chatbox, seeing other players, storing players’ information to a database, etc.

There is a site called “Building Browser Games” which has a series of tutorials on building browser based games. I haven’t looked to see when the tutorials were written so be aware that bits of the php may use functions which may have since been depreciated.

You need to know PHP & SQL for the processing of events, etc and HTML & CSS for the presentation (you should decide early on if your going to support older browsers - my own feeling on this is that you should support as far back to and including IE6 as being a game your going to have people logging in from their work place or their school/college/uni where they may well be stuck with IE6).

At a later time you may wish to consider adding AJAX to make each page more interactive without having to re-load the whole page (each page should still be usable without javascript for any person who has javascript disabled for whatever reason).

You’ll most likely use cron jobs (or an equivalent system) for running any “house-keeping” type scripts for things like: deleting inactive players, processing the outcome of battles, updating player scores, etc.

If your new to server-side programming then a couple of suggestions for books to read are:

If you run into any problems, please don’t be afraid to post in the forums, we have got forums dedicated to both PHP and [URL=“http://www.sitepoint.com/forums/mysql-182/”]MySQL.