Thursday, August 16, 2007

Coding Headache

Been looking at Kah's ArrayMap stuff, and when I tried to use the detectKeys() function it didn't work, so ended up going back to addKeyListener stuff. That seems to be working now.
Also getting my head around Flash's Action Script implementation of object orientated programming (Oop). Quite un-Java-like in terms of how loose and weakly-typed it is though kind of similar. Will 'objectify' the code a little more as it makes more sense.

The main headache has been trying to work out where I am on the map. In axonometric it is fairly complicated because of the way the tiles are laid out, you can have multiple rows occurring on the same x-axis. (It's a little hard to explain here you would have to see the code to see what I mean. I might do a pic so you can see).

Anyways decided the easiest away around this is to have a 'virtual map' and a 'drawn map'. The virtual map is the actual tile layout in a Cartesian vertical and horizontal co-ordinate system. This facilitates the following:

  • All the co-ordinates can start from 0 and be positive (i.e. don't have to worry about negative values in calculations).

  • I can use the Kah's ArrayMap logic to find adjacent tiles. i.e Keep-It-Simple-Stupid (KISS). Adjacent tiles are above/below, left and right. No weird axonometric calculations involved.

  • It is easy to translate 'virtual map' movements to 'drawn map' movements because an axonometric tile is just a normal square rotated 45 degrees. They have the same number of pixels.( Well that's my assumption. We'll see if it holds up).


Will have another bash at it today and see what comes up.

No comments: