/src/MapCollision.h

http://github.com/clintbellanger/flare · C Header · 69 lines · 33 code · 12 blank · 24 comment · 0 complexity · fe217a59cba73f278fa79d86903e3c39 MD5 · raw file

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