/src/MapCollision.h
C Header | 69 lines | 33 code | 12 blank | 24 comment | 0 complexity | fe217a59cba73f278fa79d86903e3c39 MD5 | raw file
Possible License(s): GPL-3.0
1/* 2Copyright 2011 Clint Bellanger 3 4This file is part of FLARE. 5 6FLARE is free software: you can redistribute it and/or modify it under the terms 7of the GNU General Public License as published by the Free Software Foundation, 8either version 3 of the License, or (at your option) any later version. 9 10FLARE is distributed in the hope that it will be useful, but WITHOUT ANY 11WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 14You should have received a copy of the GNU General Public License along with 15FLARE. If not, see http://www.gnu.org/licenses/ 16*/ 17 18/* 19 * MapCollision.h 20 * RPGEngine 21 * 22 * Handle collisions between objects and the map 23 */ 24 25#ifndef MAP_COLLISION_H 26#define MAP_COLLISION_H 27 28#include "Utils.h" 29#include "Settings.h" 30#include <algorithm> 31#include <cstdlib> 32#include <vector> 33 34// collision tile types 35const int BLOCKS_ALL = 1; 36const int BLOCKS_MOVEMENT = 2; 37const int BLOCKS_ALL_HIDDEN = 3; 38const int BLOCKS_MOVEMENT_HIDDEN = 4; 39 40// collision check types 41const int CHECK_MOVEMENT = 1; 42const int CHECK_SIGHT = 2; 43 44class MapCollision { 45private: 46 47 bool line_check(int x1, int y1, int x2, int y2, int checktype); 48 49public: 50 MapCollision(); 51 ~MapCollision(); 52 void setmap(unsigned short _colmap[256][256]); 53 bool move(int &x, int &y, int step_x, int step_y, int dist); 54 bool outsideMap(int tile_x, int tile_y); 55 bool is_empty(int x, int y); 56 bool is_wall(int x, int y); 57 58 bool line_of_sight(int x1, int y1, int x2, int y2); 59 bool line_of_movement(int x1, int y1, int x2, int y2); 60 bool compute_path(Point start, Point end, std::vector<Point> &path, unsigned int limit = 100); 61 62 unsigned short colmap[256][256]; 63 Point map_size; 64 65 int result_x; 66 int result_y; 67}; 68 69#endif