00001 /* 00002 Copyright Remco Bras and Michael de Lang 2007,2008. 00003 This file is part of RPGE. 00004 00005 RPGE is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 RPGE is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/> 00017 */ 00018 00019 /* 00020 tile.h: Define the tile and tilelayer structures, declare tile usage procedures. 00021 */ 00022 #ifndef TILE_H 00023 #define TILE_H 00024 00025 #include <SDL/SDL.h> 00026 #include "xalloc.h" 00027 #include "mobs.h" 00028 #include "sequence.h" 00029 00030 /*These are defined such that they match individual bits, which conveniently also work properly when added. The former property is great for C, the latter is good for GUILE. This does put an upper bound of approximately 32 on our number of allowed variations of blocking, but needing those should be rare.*/ 00031 #define BLOCK_LEFT 0x4 00032 #define BLOCK_RIGHT 0x8 00033 #define BLOCK_UP 0x10 00034 #define BLOCK_DOWN 0x20 00035 #define BLOCK_ALL BLOCK_LEFT | BLOCK_RIGHT | BLOCK_UP | BLOCK_DOWN 00036 #define BLOCK_NONE 0x0 00037 00038 typedef struct 00039 { 00040 int tilesheetindex; 00041 SDL_Rect sheetclippinginfo; 00042 char blocking; 00043 mob* occupant; /*This is a pointer to simplify matters*/ 00044 } tile; 00045 00046 typedef struct 00047 { 00048 int index; 00049 int count; 00050 } imagecounter; 00051 00052 typedef struct 00053 { 00054 tile** tilegrid; 00055 int height; 00056 int width; 00057 SDL_Surface* imagebuffer; 00058 sequence imagecounts; 00059 } tilelayer; 00060 00061 extern sequence tile_layers; 00062 extern int maingrid_index; 00063 00064 #define MAIN_GRID ((tilelayer*)tile_layers.data[maingrid_index].data) 00065 00066 void init_tiles(); 00067 tile make_tile(unsigned int tilesheet, SDL_Rect clipping, char blocking); 00068 tile** init_tilegrid(unsigned int width, unsigned int height); 00069 tile** set_all_tiles(int gridid,tile replacement); 00070 tile** set_tile(int gridid,unsigned int x, unsigned int y, tile replacement); 00071 char occupied(int tilex, int tiley,int grid); 00072 void set_occupant(int tilex, int tiley, int grid, mob* new_occupant); 00073 mob* get_occupant(int tilex, int tiley, int grid); 00074 void reset_occupant(int tilex, int tiley,int grid); 00075 int add_tilegrid(tilelayer grid); 00076 void remove_grid_at(int index); 00077 void set_maingrid_index(int ind); 00078 00079 /*Includes which depend on this file*/ 00080 #include "video.h" 00081 #endif