Each tile is identified by a set of coordinates (x,y). There are coordinates (x,y) which doesn't refer to a tile. These coordinates are called masked. The set of tiles can be viewed in various forms. For all forms the relation "tile x has coordinates (x,y)" is the same. Each of the form serves a certain function. Properties: - compact: fills a rectangle (ignoring masking) - sparse: has gaps (ignoring masking) - tile-aligned: preserves the local geometry between tiles Base Form ========= This form is the only one which operates on coordinates. All the others (as noted above) operate on tiles. The coordinates form a rectangle which has angle 0. Dimensions corresponds to map.[xy]size. Used for: internal storage Properties: compact, not sparse, maybe tile-aligned Example: grid_compact.png or below ########## ########## ########## Masked Form =========== Made out of base form by removing all masked coordinates. Used for: external storage (savegame, gamelog), whole_map Properties: compact, not sparse, maybe tile-aligned Example: below (-|+ is the bounding box, as defined by base form) +----------+ |### ######| |###### ###| |######## #| +----------+ but also +---------------+ | # | | ####### | | ######### | | ########### | | ############# | | ############# | | ############# | |###############| | ############# | | ############# | | ############# | | ########### | | ######### | | ####### | | # | +---------------+ Effective Form ============== Used for: wrapping, neighborhood (adjc_iterate, square_iterate), step (DIRSTEP, MAPSTEP) Properties: maybe compact, maybe sparse, tile-aligned This form depends if the map is an iso-map or not. Effective Form (non-iso map) ---------------------------- Equivalent to masked form. Neighborhood: (x-1, y-1) (x, y-1) (x+1, y-1) (x-1, y) (x, y) (x+1, y) (x-1, y+1) (x, y+1) (x+1, y+1) Effective Form (iso map) ------------------------ There are two variants depending on which coordinate you compress. Effective Form (iso map) variant 1 ---------------------------------- Example: grid_iso_rot.png Neighborhood: (x, y-2) (x, y-1) (x+1, y) (x-1, y-1) (x, y) (x, y+1) (x-1, y) (x-1, y+1) (x, y+2) Effective Form (iso map) variant 2 ---------------------------------- Example: grid_iso2_rot.png Neighborhood: (x, y-1) (x+1, y-1) (x+2, y) (x-1, y-1) (x, y) (x+1, y) (x-2, y) (x-1, y) (x, y+1) View Form ========= Depends on the use of iso or non-iso tileset. Used for: mapview View Form (non-iso tileset) --------------------------- Same as the effective form. Example: grid_compact.png View Form (iso tileset) ----------------------- Effective form rotated 45° right (angle=pi/4). Example: grid_iso.png, grid_iso2.png Indexed Form ============ One possible form is to concat all lines together. base form: 123456 7890ab cdefgh indexed form: 1234567890abcdefgh Used for: currently nothing. Implementation Details ====================== Base Form --------- Used for: internal storage No changes needed. Masked Form ----------- Used for: external storage (savegame, gamelog), whole_map No changes needed. Effective Form -------------- Used for: wrapping Changes needed (IMHO easy). step(DIRSTEP, MAPSTEP), simple neighborhood (adjc_iterate) Changes needed (easy if we redefine DIR_D[XY] at runtime). extended neighborhood (square_iterate), Changes needed (fairly easy if DIR_D[XY] is used).