PHP Programming > General PHP Help

Need help starting on a browser-based game

(1/18) > >>

ShieldHeart:
Hey folks,

I'm an experienced programmer and have extensive knowledge in java and visual basics, I've recently been learning how to make websites using Dreamweaver, PHP, and MySQL through Lynda.com. I'm trying to make a browser-based game similar to TribalWars, Travian, and Castle Battle. Here are the links to these games if you don't know what these games are:

http://www.tribalwars.net/
http://www.travian.com/
http://www.the-crusades.org/

I obviously don't expect to make my game nearly as professional as these games. My question is, what do I need to know before I can attempt such a project? I know that the main tools will be PHP and MySQL. I already have the game mechanics planned out and programmed in visual basic. I just need to start coding it in PHP. I'm looking for any helpful input that will help me get this started. Are there any resources I could use for coding such a game? Any input is welcome, thanks in advance.


 

ErnieAlex:
Well, you are talking about a turn-based game, correct?  Or, a 2D animated version?

Either way, you might want to learn about 2D gaming using a 3D programming game system.
The one I suggest is Unity3D.   They have a great system that has a free web plugin similar to
Flash.  ALL of it is totally free.  I am currently playing with it and found there are a lot of tutorials
online on how to program games thru it.

Also, the reason that I mentioned the above is that PHP is not really orientated to gaming.  It does
do just about everything you want, except in the graphics areas.  PHP does do enormous image
manipulations and has a ton of useful tools for graphics.  But, it is limited when it comes to actual
animation.  (I could be wrong here, but, nobody has said otherwise...)

So, if your game includes a lot of graphics, I might go with a web plugin.  There are lots out there.
Adobe Flash, or Shockwave, Unity3D webplayer, Sliverlight (I forget the game part name) and many
others.  All are easy to learn if you know VB and general programming.  Each has it's own area that
is better than others.  I like Flash, although it is tricky to learn and I really like the Unity webplayer.
The best part of Unity is that is it free...   So, if you do not have that much graphics and is just a map
or grid game, you could use PHP as it can piece together a map with avatars, scenery and others easily
merged together in a timely manor.  Not too complicated depending on the decision codes needed...

Well, doubt this helped, but, some items to think about.  Perhaps a little more info on YOUR game might
help us to help you...    LOL...  Good luck!

ShieldHeart:
Thankfully I will only be using still images as graphics so the programming task shouldn't be too complicated. But thanks for the input! I will definitely look into Unity3D.

My game will not be turn-based but time-based instead. Other than that it will also feature a grid map and a minimap to show land that each player owns. It will be very similar to those games I put up links for, take a look at them if you have the time.

PS any other input you guys have is always appreciated thank you. I'm pretty much a beginner PHP coder so this task will probably take me the whole summer to accomplish but I'm determined to learn and do this thing.

ErnieAlex:
Well, PHP is a web programming system.  It can handle limited graphics very very well.  It can also handle inputs from users and responses in a timely manor.  It runs a TON of gaming sites of different types of games.  The sites you posted are just sites with graphics and code.  We can help!  But, you have not asked any PHP questions...  It sounds, at first, like PHP will do your job.  But, what can we help you with?   Ask away...

ShieldHeart:
Alright one of the first things I need to do is populate a MySQL database with the information on the map that the users will play on. I'm new to PHP and MySQL so I would appreciate getting some help with this.

I have a MySQL table which will hold the information on each tile of the 1000x1000 map grid in the game. The columns in this table will hold the amount of resources available on that tile, the X and Y coordinates of that tile, the owner of that tile, and the type of building built on that tile (if there is any).

So the columns in this table are TileID, X coord, Y coord, %Iron, %Gold, %Fertility, %Wood, %Stone, Owner, and Building.

So far this table is empty but it will hold 1000x1000 number of values for each column. What I need to do is populate this table and essentially create the playing field which the players will play on.  I'm assuming that it's possible to do this through PHP code. I would really appreciate if you guys could help me code this first bit.

The tricky bit is that the values for the resources on each tile (aka the %Iron, %Gold, %Fertility, %Wood, %Stone columns) are generated randomly by picking a value between 50 and 100. I accomplish this in my VB version of the game by using the following code:

For X = 0 To UNISPAN
        For Y = 0 To UNISPAN
                intTIron(X, Y) = Int(((100 - 50 + 1) * Rnd()) + 50)
                intTGold(X, Y) = Int(((100 - 50 + 1) * Rnd()) + 50)
                intTFert(X, Y) = Int(((100 - 50 + 1) * Rnd()) + 50)
                intTWood(X, Y) = Int(((100 - 50 + 1) * Rnd()) + 50)
                intTSton(X, Y) = Int(((100 - 50 + 1) * Rnd()) + 50)
        Next
Next

In VB this is simply assigning the resource values into variables inside a 2D array.  I need to use PHP code to populate the columns in the same way.

I hope I was clear on what needs to get done, let me know if anything needs more clarification. Again, I appreciate any help I can get with this, thanks in advance.

Navigation

[0] Message Index

[#] Next page

Go to full version