Post by David West on Aug 21, 2006 6:46:29 GMT -5
The map is going to be generated "on the fly" to allow for a theoretical infinite map-size.
The map generator routine is initially going to be very simple as I want to get the game coded and then refine it from there, so this documentation is for that simple version of code.
First of all the "screen display" code will decide what part of the map is being looked at, centred either on a city or unit of a particular player.
The map is going to be displayed using a matrix of CSS divs (dimensions to be decided).
First of all a query is made to the database to fetch the coordinates of the central square, which is then displayed using whatever graphic suits that terrain type. The only time that will not exist is if it's a new player just starting, in which case a capital city needs to be displayed and the data which goes with it putting into the map table.
Next a loop runs through all the squares which are visible from the central location, the range of view is to be decided, but assuming it's all surrounding terrain with 4 squares, that gives a field of view of 9x9 squares.
The loop gets the terrain type for eacxh square in turn and displays it in the relevant CSS div and also cross references the unit table to see if there are any units in that particular square and if so displays a graphic for them, in whichever colour that unit is (different countries have different colours).
If the unit is friendly then it will have a link or some kind of button so you can "jump to" that unit and the screen gets redrawn with the new unit at the centre.
If the square being drawn is adjacent to the central one then a link/button for "Move here" needs to be drawn onto the square, as long as the terrain type can be traversed by the unit in question, in other words it's not sea or an enemy unit.
to be continued.........
The map generator routine is initially going to be very simple as I want to get the game coded and then refine it from there, so this documentation is for that simple version of code.
First of all the "screen display" code will decide what part of the map is being looked at, centred either on a city or unit of a particular player.
The map is going to be displayed using a matrix of CSS divs (dimensions to be decided).
First of all a query is made to the database to fetch the coordinates of the central square, which is then displayed using whatever graphic suits that terrain type. The only time that will not exist is if it's a new player just starting, in which case a capital city needs to be displayed and the data which goes with it putting into the map table.
Next a loop runs through all the squares which are visible from the central location, the range of view is to be decided, but assuming it's all surrounding terrain with 4 squares, that gives a field of view of 9x9 squares.
The loop gets the terrain type for eacxh square in turn and displays it in the relevant CSS div and also cross references the unit table to see if there are any units in that particular square and if so displays a graphic for them, in whichever colour that unit is (different countries have different colours).
If the unit is friendly then it will have a link or some kind of button so you can "jump to" that unit and the screen gets redrawn with the new unit at the centre.
If the square being drawn is adjacent to the central one then a link/button for "Move here" needs to be drawn onto the square, as long as the terrain type can be traversed by the unit in question, in other words it's not sea or an enemy unit.
to be continued.........