The beginnings

I finally worked out how to display a table with individual cell IDs representing the coordinates for my current project (It’s called Kingdom of Might – cliché, but then again it’s just a project name for now). And now it is just a simple matter of displaying the content in each individual cell using an array like $content[$id]. Took a while to figure out the math and the centre cell positioning, but now I got it worked out.

(There will be a sight attribute to the game, which decides how many grids you can actually see.)

Stage 1: Labeling each individual cell with an ID. Note that the first cell is blank due to it having a value of 0.

Stage 2: Determining the ID of the center cell.

I use this formula: c = [s(1+2s)] + s
where c is the centre cell id and s is the sight attribute from the database

Stage 3: Putting everything together.

And the code that made it work:

Leave a comment

Your email address will not be published. Required fields are marked *