diff options
author | jonas <himself@jonasgunz.de> | 2019-03-04 00:47:23 +0100 |
---|---|---|
committer | jonas <himself@jonasgunz.de> | 2019-03-04 00:47:23 +0100 |
commit | a94557f5119ca5cac0ecf970b02180152af83f5d (patch) | |
tree | 905245f181305d0fc40edd802423294acb5c4686 /test.cpp | |
parent | d25296d03fdaeaadd002cd37171ef2b20695cf26 (diff) | |
download | termgl-a94557f5119ca5cac0ecf970b02180152af83f5d.tar.gz |
Started collision detection, working progress
Move now triggers CheckCollision for every move action
Hit direction detection still missing
Diffstat (limited to 'test.cpp')
-rw-r--r-- | test.cpp | 48 |
1 files changed, 11 insertions, 37 deletions
@@ -32,6 +32,11 @@ public: drawPoint('Q', _pos, true, _COL_YELLOW); } + virtual bool onCollisionActive(unsigned int _hit, int _passiveObject){ + drawPoint('K', {0,0}, true, _COL_RED); + return true; + } + virtual void onChar(unsigned char _c) { drawPoint(_c, {1,1},true, _COL_BLUE); } private: int cc; @@ -42,7 +47,6 @@ int main(int argc, char* argv[]) cRender render(' ', _COL_DEFAULT, 30,30); cObjectHandler handler(&render); cObject ver(45,1); - cWiremesh obj; testobject obj2; cInput input; @@ -60,37 +64,15 @@ int main(int argc, char* argv[]) ver.drawText(DATE, {20,0}, _COL_WHITE); ver.drawText(VERSTRING, {0,0}, _COL_WHITE); int iver = handler.createObject(&ver); - handler.moveObject(iver, {0,0}, _MOVE_ABSOLUTE); - - int x = 15; - int y = 15; - int z = 30; - - obj.addVector({-x,-y,z}, {2*x,0,0}, '+', _COL_RED); - obj.addVector({-x,-y,z}, {0,2*y,0}, '+', _COL_RED); - obj.addVector({-x,y,z}, {2*x,0,0}, '+', _COL_RED); - obj.addVector({x,-y,z}, {0,2*y,0}, '+', _COL_RED); - - obj.addVector({-x,-y,0}, {0,0,z}, ':', _COL_RED); - obj.addVector({x,-y,0}, {0,0,z}, ':', _COL_RED); - obj.addVector({-x,y,0}, {0,0,z}, ':', _COL_RED); - obj.addVector({x,y,0}, {0,0,z}, ':', _COL_RED); - - obj.addVector({-x,-y,0}, {2*x,0,0}, ',', _COL_RED); - obj.addVector({-x,-y,0}, {0,2*y,0}, ',', _COL_RED); - obj.addVector({-x,y,0}, {2*x,0,0}, ',', _COL_RED); - obj.addVector({x,-x,0}, {0,2*y,0}, ',', _COL_RED); - int imesh = handler.createWiremesh(&obj); + handler.moveObject(iver, {0,0}, _MOVE_FORCE_ABSOLUTE); int iobj2 = handler.createObject((cObject*)&obj2); - handler.moveObject(iobj2, {3,3}, _MOVE_ABSOLUTE); + handler.moveObject(iobj2, {3,3}, _MOVE_FORCE_ABSOLUTE); sPos middle = render.getSize(); middle.x /= 2; middle.y /= 2; - handler.moveWiremesh(imesh,{middle.x,middle.y,0}, _MOVE_ABSOLUTE); - while( loop ) { sInputEvent ie = input.poll(); @@ -126,22 +108,16 @@ int main(int argc, char* argv[]) switch(ie.c) { case 'w': - handler.rotateWiremesh(imesh,{-10,0,0}); + handler.moveObject(iobj2, {0,-1}, _MOVE_RELATIVE); break; case 's': - handler.rotateWiremesh(imesh,{10,0,0}); + handler.moveObject(iobj2, {0,1}, _MOVE_RELATIVE); break; case 'a': - handler.rotateWiremesh(imesh,{0,-10,0}); + handler.moveObject(iobj2, {-1,0}, _MOVE_RELATIVE); break; case 'd': - handler.rotateWiremesh(imesh,{0,10,0}); - break; - case 'q': - handler.rotateWiremesh(imesh,{0,0,-10}); - break; - case 'e': - handler.rotateWiremesh(imesh,{0,0,10}); + handler.moveObject(iobj2, {1,0}, _MOVE_RELATIVE); break; }; } @@ -151,8 +127,6 @@ int main(int argc, char* argv[]) } } - handler.rotateWiremesh(imesh,{1,1,1}); - handler.write(); render.render(); framecounter++; |