Closed daniel-santos closed 12 years ago
From b4b61c7f73a04d3cfcb7e8a703fcfa66aa1f2a16 Mon Sep 17 00:00:00 2001 From: Daniel Santos daniel.santos@pobox.com Date: Wed, 18 Apr 2012 02:27:14 -0500 Subject: Don't get stuck on jagged walls, stray rocks and sticky-outy things.
When traveling straight (not diagonally), and we hit an object, but if one step to the left or right (relative to our direction of travel) there is a valid path, then desist movement in the requested direction and travel towards the clear path on the other axis until we can proceed
src/MapCollision.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++------- src/MapCollision.h | 4 ++ 2 files changed, 73 insertions(+), 12 deletions(-)
diff --git a/src/MapCollision.cpp b/src/MapCollision.cpp index 5809e2b..c198532 100644 --- a/src/MapCollision.cpp +++ b/src/MapCollision.cpp @@ -48,10 +48,9 @@ void MapCollision::setmap(unsigned short _colmap[256][256]) { */ bool MapCollision::move(int &x, int &y, int step_x, int step_y, int dist) {
return !ret ? 0 : (ret == 1 ? -1 : 1); }
bool MapCollision::is_wall(int x, int y) { diff --git a/src/MapCollision.h b/src/MapCollision.h index 897cc84..71b3db9 100644 --- a/src/MapCollision.h +++ b/src/MapCollision.h @@ -53,6 +53,7 @@ public: bool move(int &x, int &y, int step_x, int step_y, int dist); bool outsideMap(int tile_x, int tile_y); bool is_empty(int x, int y);
int is_one_step_around(int x, int y, int xidr, int ydir); bool is_wall(int x, int y);
bool line_of_sight(int x1, int y1, int x2, int y2); @@ -64,6 +65,9 @@ public:
int result_x; int result_y; + +private:
bool inline is_sidestepable(int tile_x, int tile_y, int offx1, int offy1, int offx2, int offy2); };
1.7.3.4
sorry, wrong project! was intended for clintbellanger/flare
This is kinda annoying. hmm, not sure how to attach patches on github....