Wednesday, April 8, 2009

The Grid

While I was playing some WAR last Friday, I was chatting with my friend Marc about doing some iPhone work on Saturday. We talked about things we would be focusing on during our dev sessions. He started talking about doing specific modules needed for his game (like actual gameplay stuff) while I was talking about learning how to do animations (something that in theory I need but not for a while). This really got me inspired to change up my approach (again) to developing this game. What I need to do is actually make stuff for the game and when tech needs arise, make them but not try to build "engine" components way ahead of time. The major benefit of this is getting to see the game unfold as I develop the tech vs having to implement later and being left with a bunch of rather useless tech demos.

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:
  1. Turn the coordinate into "tile coordinates" by using the max width/height of a hex.
  2. Find the hex based on that coordinate (assuming hexes are square).
  3. Using some kind of point/polygon test (yeaaah!), test all hexes that neighbor that hex until you find the exact one that was touched.
The Map Generation...well I'm working on an idea that Marc suggested: Seed random spots on the map and come up with some method for how they grow and expand on their own until they hit some size then analyze what kind of map is created. This more involved but I may try to setup the basic interace to this and work on another night. One good test would be to cross this growing method with the touch interaction...we could let users create their own maps to play on :).

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.

No comments:

Post a Comment