From a94557f5119ca5cac0ecf970b02180152af83f5d Mon Sep 17 00:00:00 2001 From: jonas Date: Mon, 4 Mar 2019 00:47:23 +0100 Subject: Started collision detection, working progress Move now triggers CheckCollision for every move action Hit direction detection still missing --- cObjectHandler.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'cObjectHandler.h') diff --git a/cObjectHandler.h b/cObjectHandler.h index 0e7750c..1e872b3 100644 --- a/cObjectHandler.h +++ b/cObjectHandler.h @@ -8,9 +8,16 @@ //movemodes #define _MOVE_RELATIVE 0 #define _MOVE_ABSOLUTE 1 +#define _MOVE_FORCE_ABSOLUTE 2 using namespace std; +struct sCollision +{ + unsigned int *idv; + int *hitv; + unsigned int idc; +}; /** * Manages cObject and cWiremesh and writes them to a cRender framebuffer. @@ -32,7 +39,8 @@ public: /** * Alters position of _object by _pos either relative to old position or Absolute - * Depending on selected _mode (_MOVE_RELATIVE / _MOVE_ABSOLUTE). + * Depending on selected _mode (_MOVE_RELATIVE / _MOVE_ABSOLUTE / _MOVE_ABSOLUTE). + * _MOVE_ABSOLUTE not recommended: Collision is only checked at destination. To ensure initialisation, use _MOVE_FORCE_ABSOLUTE! */ int moveObject(int _object, sPos _pos, int _mode); @@ -89,6 +97,8 @@ public: private: + sCollision checkCollision(sPos _pos, sPos _size); + void buildHitmap(); vector objects; -- cgit v1.2.3