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 --- cObject.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'cObject.h') 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 -- cgit v1.2.3