1 /************************************************************** 2 * _____ __ _____ * 3 * / _ \ | | ____ ___ ___ / | | * 4 * / /_\ \ | | _/ __ \ \ \/ / / | |_ * 5 * / | \| |__\ ___/ > < / ^ / * 6 * \____|__ /|____/ \___ >/__/\_ \ \____ | * 7 * \/ \/ \/ |__| * 8 * * 9 ************************************************************** 10 * (c) Free Lunch Design 2003 * 11 * Written by Johan Peitz * 12 * http://www.freelunchdesign.com * 13 ************************************************************** 14 * This source code is released under the The GNU * 15 * General Public License (GPL). Please refer to the * 16 * document license.txt in the source directory or * 17 * http://www.gnu.org for license information. * 18 **************************************************************/ 19 20 21 22 #ifndef _MAP_H_ 23 #define _MAP_H_ 24 25 #include <stdio.h> 26 #include "allegro.h" 27 28 // some directions for expanding/shrinking the map 29 #define SM_UP 0x01 30 #define SM_DOWN 0x02 31 #define SM_RIGHT 0x04 32 #define SM_LEFT 0x08 33 34 // the items 35 #define MAP_EGG 1 36 #define MAP_DEAD 2 37 #define MAP_EXIT 3 38 #define MAP_1UP 4 39 #define MAP_SPIN 5 40 #define MAP_BRK 6 41 #define MAP_STAR 7 42 #define MAP_CHERRY 8 43 #define MAP_HEART 9 44 #define MAP_LOLA 10 45 46 // the enemies ... 47 #define MAP_ENEMY1 101 48 #define MAP_ENEMY2 102 49 #define MAP_ENEMY3 103 50 #define MAP_ENEMY4 104 51 #define MAP_ENEMY5 105 52 #define MAP_ENEMY6 106 53 // ... and the bosses 54 #define MAP_GUARD1 151 55 #define MAP_GUARD2 152 56 57 // water tiles 58 #define MAP_WATER 201 59 #define MAP_SURFACE 202 60 61 // win conditions 62 #define MAP_WIN_EXIT 1 63 #define MAP_WIN_KILL_GUARDIAN 2 64 #define MAP_WIN_KILL_ALL 4 65 66 // a position on the tile map 67 typedef struct { 68 unsigned char tile; // #id in tile set 69 unsigned char mask; // #id in mask set 70 unsigned char type; // what type has this tile? 71 unsigned char item; // does this slot have an item? 72 } Tmappos; 73 74 // map header (overall stuff) 75 typedef struct { 76 char name[32]; 77 char dummy[27]; 78 char map_data_needs_to_be_destroyed; 79 char win_conditions_fullfilled; 80 char num_enemies; 81 char boss_level; 82 char win_conditions; 83 int width, height; 84 Tmappos *dat; 85 int offset_x; 86 int offset_y; 87 DATAFILE *data; 88 int start_x; 89 int start_y; 90 } Tmap; 91 92 93 // functions 94 Tmap *create_map(int w, int h); 95 void destroy_map(Tmap *m); 96 Tmap *load_map(char *fname); 97 Tmap *load_map_from_memory(void *mem); 98 int save_map(Tmap *m, char *fname); 99 void change_map_size(Tmap *m, int dw, int dh, int dir_flags); 100 101 void draw_map(BITMAP *bmp, Tmap *m, int dx, int dy, int w, int h, int edit); 102 103 Tmappos *get_mappos(Tmap *m, int tx, int ty); 104 105 int set_tile(Tmap *m, int tx, int ty, int tile); 106 int get_tile(Tmap *m, int tx, int ty); 107 108 int is_ground(Tmap *m , int x, int y); 109 int adjust_ypos (Tmap *m, int x, int y, int ground, int dy); 110 int adjust_xpos (Tmap *m, int x, int y, int ground, int dx); 111 112 113 114 #endif