1 /* 2 XorGramana Copyright 2009 James W. Morris, james@jwm-art.net 3 4 This file is part of XorGramana. 5 6 XorGramana is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 XorGramana is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with XorGramana. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #ifndef _MAP_H 20 #define _MAP_H 21 22 #include "types.h" 23 #include "defs.h" 24 #include <stdio.h> 25 26 struct xy 27 { 28 xy_t x; 29 xy_t y; 30 }; 31 32 struct xg_map 33 { 34 char* filename; 35 char* title; 36 ctr_t max_moves; /* number of moves allowed to complete a level */ 37 su_t width; 38 su_t height; 39 map_t** data; 40 struct xy view[2]; /* start coords of initial player views (gen) */ 41 struct xy mappc[4]; /* coords of map piece 0 1 2 3 */ 42 struct xy player[2]; /* positions - by scanning map-data */ 43 struct xy teleport[2]; /* positions, scanned */ 44 struct xy exit; /* exit position */ 45 su_t level; /* user's choice */ 46 su_t mask_count; 47 map_t* solve_word[MAX_WORDS_TO_SOLVE+1]; 48 struct xy solve_xy[MAX_WORDS_TO_SOLVE+1]; 49 xy_t solve_y[MAX_WORDS_TO_SOLVE+1]; 50 su_t solve_dir[MAX_WORDS_TO_SOLVE+1]; 51 struct xy solve_unblock_xy[MAX_WORDS_TO_SOLVE+1]; 52 bool solved[MAX_WORDS_TO_SOLVE+1]; 53 }; 54 55 /* the solutions take the form of: * 56 * 1) a list of words * 57 * 2) a list of x,y positions for first letter of each word * 58 * 3) a list of directions right,down how each word should be * 59 * placed. * 60 * (once the player has arranged letters such that these words * 61 * can be read at the respective positions in the map, then * 62 * player can finish the level and go through the exit.) */ 63 64 extern struct xg_map* map; 65 66 void xg_map_create(const char* title, int width,int height); 67 void xg_map_destroy(); 68 void xg_map_load(su_t level); 69 70 void xg_map_init_views(xy_t view_w, xy_t view_h); 71 72 char* xg_map_read_name(FILE* fp); 73 char* xg_map_load_read_name(su_t level); 74 75 /* map_get_teleport checks the coordinates passed against 76 those in the map->teleports array and returns 0 if 77 coordinate is teleport 0, and 1 if coordinate is teleport 78 1. returns 99 if coord is not a teleport. 79 */ 80 su_t map_get_teleport(xy_t x, xy_t y); 81 82 /* brute force exit(1) */ 83 void xg_map_load_error(FILE* fp, char* filename, char* msg); 84 85 void xg_map_apply_edging(); 86 87 bool is_wall(xy_t x, xy_t y); 88 89 /* test map against word solutions, return TRUE if all matches */ 90 bool map_check_solved(); 91 92 #ifdef MAPDEVMODE 93 void map_dump_solve_state(); 94 #endif 95 96 #endif /* _MAP_H */ 97