diff options
author | jonas <himself@jonasgunz.de> | 2018-12-26 21:18:09 +0100 |
---|---|---|
committer | jonas <himself@jonasgunz.de> | 2018-12-26 21:18:09 +0100 |
commit | 616951a353caf398908e6e6ce7dddf34a65513e5 (patch) | |
tree | 36a5ac46861b3f2c21777d383359f8463676e404 /AmpelJonas/main.cpp | |
parent | 905f5ad1f16d2ea719eb40c311609f8fad46fd95 (diff) | |
download | termgl-616951a353caf398908e6e6ce7dddf34a65513e5.tar.gz |
Added cInput input handler class
cRender: +setConsoleCursor(bool) to disable console cursor
main: Example workign with cInput
cInput: Input handler class
Diffstat (limited to 'AmpelJonas/main.cpp')
-rw-r--r-- | AmpelJonas/main.cpp | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/AmpelJonas/main.cpp b/AmpelJonas/main.cpp index 18b483e..f0f6f50 100644 --- a/AmpelJonas/main.cpp +++ b/AmpelJonas/main.cpp @@ -3,10 +3,53 @@ #include "cRender.h" #include "cObject.h" #include "cObjectHandler.h" +#include "cInput.h" int main() { - unsigned long int framecounter = 0; + cRender a(' ', _COL_DEFAULT, 20,20); + cInput in; + a.render(); + + sPos size = a.getSize(); + sPos pos = {size.x / 2, size.y / 2}; + + while(1) + { + sInputEvent ie = in.poll(); + if(ie.type != _EVENT_NULL) + { + if(ie.type == _EVENT_KEY) + { + switch (ie.c) + { + case 'A': + pos.y--; + break; + case 'B': + pos.y++; + break; + case 'C': + pos.x++; + break; + case 'D': + pos.x--; + break; + }; + } + else if (ie.type == _EVENT_MOUSE) + { + pos.x = ie.x; + pos.y = ie.y; + } + + a.clear(); + a.drawPoint('X', pos, true, _COL_GREEN); + a.render(); + } + } + + /*unsigned long int framecounter = 0; cRender a(' ', _COL_DEFAULT, 10,10); a.render(); @@ -45,7 +88,9 @@ int main() framecounter++; //cin.get(); //usleep(100*1000); - } + if(framecounter >= 1000) + break; + }*/ /*cObjectHandler b(&a); cObject x(1,1); |