View Single Post
Old 03-22-2004, 05:43 PM   #2 (permalink)
Yakk
Wehret Den Anfängen!
 
Location: Ontario, Canada
I'd maintain two mappings.

Item->Allocation Slot
Allocation Slot->ItemID

Items have status usually, slots don't have status. You could give allocation slots damage in order to prevent multiple hits to the same spot, but I don't think that is worth it.

So, your mech becomes a collection of of "items" (including gyroscopes, weapons, cockpit, engine, etc), and a collection of allocation spots, each knowing about the other.

On a hit to an allocation spot, you look up which item is damaged, then you apply the damage to the item.

Quote:
I've been thinking about using an array for it, but that array would also be kinda hefty
Numbers less than 1 million are not hefty. =)

A traditional way to deal with a hex board is to treat it as a grid with a skew on it.

Imagine taking grid paper, and shifting each row by half a "grid size" in turn. Notice that each cell is now in contact with 6 other cells... And, it isn't that hard to know which grid cells are adjacent to each other.

Maintain an array of "struct"s for a zone map:
typedef hex_element zone_map[max_zone_size][max_zone_size];

struct hex_element {
terrain_type basic_type;
bool on_fire;
bool smokey;
bool full_of_chickens;
};

If your terrain is sparse, you can do this a bit better, but at the battle-mech scale of maps, this is good enough.
__________________
Last edited by JHVH : 10-29-4004 BC at 09:00 PM. Reason: Time for a rest.
Yakk is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73