3 Copyright (C) 2003 Nuno Subtil
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 /* $Id: map.h,v 1.2 2003/11/22 17:32:10 nsubtil Exp $ */
25 #define MAP_WALL_NONE 0
26 #define MAP_WALL_VERTICAL 1
27 #define MAP_WALL_HORIZONTAL 2
32 /* only ghosts may traverse this wall */
33 #define MAP_WALL_GHOST_ONLY 7
35 #define MAP_CONTENT_NONE 0
36 #define MAP_CONTENT_FOOD 1
37 #define MAP_CONTENT_PILL 2
38 #define MAP_CONTENT_TELEPORT 3
40 #define MAP_FLAGS_NONE 0
41 #define MAP_FLAG_PACMAN_START_POSITION 1
42 #define MAP_FLAG_GHOST_START_POSITION 2
43 #define MAP_FLAG_BOMB 4
48 #define FOOD_TYPE_NORMAL 0
49 /* respawns after being eaten */
50 #define FOOD_TYPE_RESPAWN 1
51 /* respawns, disappears */
52 #define FOOD_TYPE_INTERMITTENT 2
54 #define FOOD_STATUS_ACTIVE 0
55 #define FOOD_STATUS_EATEN 1
63 /* INTERMITTENT: food disappears after being active for active_time seconds */
65 /* INTERMITTENT: food fades out during last fade_out seconds */
68 /* INTERMITTENT/RESPAWN: food respawns after inactive_time seconds */
70 /* INTERMITTENT/RESPAWN: food fades in during last fade_in seconds */
77 #define PILL_STATUS_ACTIVE 0
78 #define PILL_STATUS_EATEN 1
80 /* angular frequency (rad/s) */
81 #define PILL_BOB_FREQUENCY 4.0
106 /* content type (food, pill, teleport, etc) */
111 struct pacman_food food
;
112 struct pacman_pill pill
;
113 struct teleport teleport
;
119 /* ghost direction towards nearest spawn on this tile */
121 /* ghost direction when ghost is alive (for exits, etc) */
130 struct map_tile
**tiles
;
133 #define MAP(map, x, y) map->tiles[y][x]
134 #define MAP_CONTENT_DATA(map, x, y) map->tiles[y][x].content_data
135 #define MAP_CAN_ENTER(map, x, y) (x >= 0 && x < map->width && y >= 0 && y < map->height && MAP(map, x, y).wall == MAP_WALL_NONE)// && MAP(map, x, y).content != MAP_CONTENT_TELEPORT)
136 #define MAP_CAN_ENTER_GHOST(map, x, y) (x >= 0 && x < map->width && y >= 0 && y < map->height && (MAP(map, x, y).wall == MAP_WALL_NONE || MAP(map, x, y).wall == MAP_WALL_GHOST_ONLY))// && MAP(map, x, y).content != MAP_CONTENT_TELEPORT)
138 #define MAP_FOOD(map, x, y) MAP(map, x, y).c_data.food
139 #define MAP_PILL(map, x, y) MAP(map, x, y).c_data.pill
140 #define MAP_TELEPORT(map, x, y) MAP(map, x, y).c_data.teleport
142 struct map
*map_load_from_ascii(char **game_map
, char **ghost_map
, int width
, int height
);
143 void map_free(struct map
*map
);
144 void map_update(struct map
*map
, float delta
);
145 int map_collision_square(struct game
*game
, int x
, int y
);
146 int map_detect_collision(struct game
*game
, float start_pos
[3], float end_pos
[3], int ret
[2]);
147 int map_inside(struct game
*game
, int x
, int y
);