aboutsummaryrefslogtreecommitdiff
path: root/cObject.h
diff options
context:
space:
mode:
authorGravatar jonas <himself@jonasgunz.de> 2019-03-04 00:47:23 +0100
committerGravatar jonas <himself@jonasgunz.de> 2019-03-04 00:47:23 +0100
commita94557f5119ca5cac0ecf970b02180152af83f5d (patch)
tree905245f181305d0fc40edd802423294acb5c4686 /cObject.h
parentd25296d03fdaeaadd002cd37171ef2b20695cf26 (diff)
downloadtermgl-a94557f5119ca5cac0ecf970b02180152af83f5d.tar.gz
Started collision detection, working progress
Move now triggers CheckCollision for every move action Hit direction detection still missing
Diffstat (limited to 'cObject.h')
-rw-r--r--cObject.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/cObject.h b/cObject.h
index d0947da..50b9d18 100644
--- a/cObject.h
+++ b/cObject.h
@@ -3,8 +3,12 @@
#include "cRender.h"
-struct sObject
+#define _HIT_TOP 1
+#define _HIT_BOTTOM 2
+#define _HIT_LEFT 3
+#define _HIT_RIGHT 4
+struct sObject
{
sPos pos;
WORD **wColor;
@@ -60,6 +64,20 @@ public:
*/
virtual void onChar(unsigned char _c){}
+
+ /** Called by cObjectHandler if Object hits another during move operation
+ * return true to abort move, false to continue and allow overlap
+ */
+ virtual bool onCollisionActive(unsigned int _hit, int _passiveObject) { return false; }
+
+ /** Called by cObjectHandler if Object is hit by another object
+ * return any integer value to be identified by hitting object
+ */
+ virtual int onCollisionPassive(unsigned int _hit) { return 0; }
+
+
+
+
protected: //For child classes
cObject();
/** For inheriting classes: sets size of framebuffer