+ Reply to Thread
Results 1 to 4 of 4

Thread: PHP - browser game

  1. #1
    stef van de ven is offline x10Hosting Member stef van de ven is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    9

    PHP - browser game

    Hi all,

    I am developing a browser game, this forces me to use PHP.
    Because this is my first attempt to develop a game like that, I face some problems. One problem I face is that I really don't know where to put variables.

    What do I mean with variables?
    For example, you have a town hall and that is the middle point of your empire.
    You start with a town hall level 1, maximal inhabitants of 200.
    Eventually your amount of inhabitants will reach the 200 limit, to get more inhabitants you need a bigger city, a higher level of town hall. A level 2 townhall costs 500 wood.

    In this text above you see a few variables;
    - town hall level
    - maximal inhabitants
    - building costs

    In the future more buildings will be released to supply for wood for example.
    These variables have to be saved somewhere, that's for sure, but I don't know where and how to do that.

    So,
    Where do I have to save these variables? (database? / a .php file?)
    How to create such files, what kind of codes do I need?
    Are there any examples I can use?
    Do you know a website or a book I can use for resources?

    Thanks for your time!
    Stef

  2. #2
    mindstorm8191 is offline x10Hosting Member mindstorm8191 is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    19

    Re: PHP - browser game

    When you learn how to use databases, you will find that they are powerful tools to manage your data. I, too, am creating a browser-based game. So far I have stored all the game's related data in the database, and haven't run across any problems in doing so. I can access any specific data whenever I need it, and modify the data whenever necessary.

    There are many database engines; I know x10hosting supports mysql, and perhaps one or two more. But from a database user's standpoint the engine doesn't matter until you start using special features. To learn what you need to know about using them, Google should provide you with many different tutorials, and you can search for specific topics / subjects / commands as you need.

    Don't worry so much about interfacing with a database from PHP. At least with MySQL, running any database command is handled via one command from PHP, where you can select data from records, insert, update or delete any record as you wish. Reading data from a select command is somewhat simple, too, though there are several options. I usually do a select * from a table, and then use mysql_fetch_assoc(), passing the result of the query command. the result is a list-array (sorry I don't know my php data types that well) where you can use, for example, $player['wood'], to get the amount of wood for that given record.

    If that doesn't make much sense, read some tutorials and it may start clicking for you. Good luck.

  3. #3
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: PHP - browser game

    Right now, it sounds like you're trying to build a level 40 town hall with only 10 wood ;)

    All joking aside, you're getting into a very very complicated scenario and you don't have all the tools you need to do it yet. I would start with some beginner's tutorials and work your way up. You should also know that PHP doesn't do very well with anything graphical. I think you're working your way towards more of a Java type program. There are many good PHP text only games, but I thought I'd mention this

    You won't have your game done by the end of the week, month, or probably even year. But if you're patient and work hard, you can be an excellent programmer before you know it!
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  4. #4
    stef van de ven is offline x10Hosting Member stef van de ven is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    9

    Re: PHP - browser game

    I already have a database for members, and I have a login script working with sessions. So PHP and mysql wont be a big problem, and like many people say, there is always something called: 'Google'.

    I wanted to know where to store the variables and now I know that I have to store it into the database.

    I think I know what to do, and if not, I'll come back here ;)

    Thanks all!

+ Reply to Thread

Similar Threads

  1. Browser Based Travian game.....Real Time Strategy.....
    By admintwo in forum Gamer's Lounge
    Replies: 2
    Last Post: 01-19-2010, 01:28 PM
  2. Places to learn php
    By JaWasabi in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 01-13-2009, 02:03 AM
  3. Replies: 0
    Last Post: 12-24-2008, 03:59 PM
  4. Im gonna make a PHP text based game
    By Xenon Design in forum Off Topic
    Replies: 25
    Last Post: 10-19-2006, 05:44 AM
  5. x10 PHP Game
    By Corey in forum News and Announcements
    Replies: 21
    Last Post: 10-18-2006, 05:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers