So a large portion of th game is based around a hex grid. This is filled up to create territories which player(s) vie over. Ryan wants the game to have randomly generated maps which is a scary thought for me cause I've never had to deal with complex algorhitms like that. Oh well its about time I tried to challenge myself.
I have already got a basic model / view mumbo jumbo going with the grid. I've seperated the data for the grid from the actual object that renders it and provides the front end (for user interaction like touches). My next objectives are allow the user to click on the grid and producing the proper hex (or hexes) that they touched and also attempting a "seeding" model for random generation.
I've been thinking of how to properly do the touch detection. What I'm gonna try tonight is:
- Turn the coordinate into "tile coordinates" by using the max width/height of a hex.
- Find the hex based on that coordinate (assuming hexes are square).
- Using some kind of point/polygon test (yeaaah!), test all hexes that neighbor that hex until you find the exact one that was touched.
Another objective if I have time is to take all my coordinate translation stuff so far and formalize it. Right now its a bit scattered and not really reusable without a ton of hacked code.
I feel that this approach to development is going to be more ideal (along with previous "proper planning and not reckless coding" apporach) and will also produce a prototype much faster and also more naturally.