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.