home · contact · privacy
Some code-internal restructuring following the assumption that game map height /
[plomrogue] / src / server / map.h
1 /* src/server/map.h
2  *
3  * Struct for the game map and routines to create and scroll on it.
4  */
5
6 #ifndef MAP_H
7 #define MAP_H
8
9 #include <stdint.h> /* uint8_t */
10 #include "../common/yx_uint8.h" /* yx_uint8 struct */
11 #include "../common/yx_uint16.h" /* yx_uint16 struct */
12
13
14
15 struct Map
16 {
17     struct yx_uint16 size; /* Map's height/width (use max. 256x256)! */
18     char * cells; /* Sequence of bytes encoding map cells. */
19     uint8_t dist_orthogonal; /* Ratio of the diagonal movement penalty as   */
20     uint8_t dist_diagonal;   /* encoded by (.dist_diagonal/.dist_orthonal). */
21 };
22
23
24
25 /* Initialize island map "~" cells representing water and "." cells representing
26  * land. The shape of the island is generated randomly by starting with a sea
27  * containing one land cell in the middle and then going into a cycle of
28  * repeatedly selecting a random cell on the map and transforming it into a land
29  * cell if it is horizontally or vertically neighbor to one; the cycle ends when
30  * a land cell is due to be created right at the border of the map.
31  */
32 extern void init_map();
33
34 /* Check if coordinate "pos" on (or beyond) world.map is accessible to map
35  * object movement.
36  */
37 extern uint8_t is_passable(struct yx_uint8 pos);
38
39
40
41 #endif