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