home · contact · privacy
Added diagonal movement, with a 1.4 penalty.
[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_uint16.h" /* yx_uint16 struct */
11
12
13
14 struct Map
15 {
16     struct yx_uint16 size; /* Map's height/width in number of cells. */
17     char * cells; /* Sequence of bytes encoding map cells. */
18     uint8_t dist_orthogonal; /* Ratio of the diagonal movement penalty as   */
19     uint8_t dist_diagonal;   /* encoded by (.dist_diagonal/.dist_orthonal). */
20 };
21
22
23
24 /* Initialize island map "~" cells representing water and "." cells representing
25  * land. The shape of the island is generated randomly by starting with a sea
26  * containing one land cell in the middle and then going into a cycle of
27  * repeatedly selecting a random cell on the map and transforming it into a land
28  * cell if it is horizontally or vertically neighbor to one; the cycle ends when
29  * a land cell is due to be created right at the border of the map.
30  */
31 extern void init_map();
32
33 /* Check if coordinate "pos" on (or beyond) world.map is accessible to map
34  * object movement.
35  */
36 extern uint8_t is_passable(struct yx_uint16 pos);
37
38
39
40 #endif