3 * Struct for the game map and routines to manipulate it.
11 #include "yx_uint16.h" /* for yx_uint16 and dir enums */
17 struct yx_uint16 size; /* map's height/width in number of cells */
18 struct yx_uint16 offset; /* the map scroll offset */
19 char * cells; /* sequence of bytes encoding map cells */
24 /* Initialize an island map as 64 x 64 cells of "~" cells representing water and
25 * "." cells representing land. The shape of the island is generated randomly by
26 * starting with a sea containing one land cell in the middle and then going
27 * into a cycle of repeatedly selecting a random cell on the map and
28 * transforming it into a land cell if it is horizontally or vertically neighbor
29 * to one; the cycle ends when a land cell is due to be created right at the
30 * border of the map. The map scroll offset is initialized to 0,0.
32 extern struct Map init_map();
34 /* Scroll map into direction "dir" by changing the scroll offset if that does
35 * not push the map view beyond the size of the map window as described by
38 extern void map_scroll(struct Map * map, enum dir d, struct yx_uint16 win_size);
40 /* Scroll map to center on the "object" by changing the scroll offset following
41 * (and constrained by) the window size as described by "win_size".
43 extern void map_center_object(struct Map * map, struct MapObj * object,
44 struct yx_uint16 win_size);