aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorGravatar jonas <himself@jonasgunz.de> 2018-12-28 15:09:41 +0100
committerGravatar jonas <himself@jonasgunz.de> 2018-12-28 15:09:41 +0100
commit167abfe3746df80dd48dd65751583d97449e55f3 (patch)
treec308f70936e378eca8b68208a379e0458de934b4 /main.cpp
parentc5af4c3057a904f2a037a624273c1c7a4b0295a5 (diff)
downloadtermgl-167abfe3746df80dd48dd65751583d97449e55f3.tar.gz
Fixes in cObjectHandler:buildHitmap(), new Sample
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp60
1 files changed, 58 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index 786194a..94f834c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -5,9 +5,65 @@
#include "cObjectHandler.h"
#include "cInput.h"
+#include "testobject.h"
+
int main()
{
- cRender a(' ', _COL_DEFAULT, 20,20);
+ cRender render(' ', _COL_DEFAULT, 30,30);
+ cObjectHandler handler(&render);
+ testobject obj;
+ cInput input;
+
+ render.render();
+
+ int iobj = handler.createObject((cObject*)&obj);
+ handler.moveObject(iobj, {10,10}, _MOVE_ABSOLUTE);
+
+ while(1)
+ {
+ sInputEvent ie = input.poll();
+ if(ie.type != _EVENT_NULL)
+ {
+ if(ie.type == _EVENT_KEY)
+ {
+ switch (ie.c)
+ {
+ case 'A'://up
+ handler.moveObject(iobj, {0,-1}, _MOVE_RELATIVE);
+ break;
+ case 'B'://down
+ handler.moveObject(iobj, {0,1}, _MOVE_RELATIVE);
+ break;
+ case 'C'://right
+ handler.moveObject(iobj, {1,0}, _MOVE_RELATIVE);
+ break;
+ case 'D'://left
+ handler.moveObject(iobj, {-1,0}, _MOVE_RELATIVE);
+ break;
+ };
+ }
+ else if (ie.type == _EVENT_MOUSE)
+ {
+ if(ie.b == 0)
+ handler.clickEvent({ie.x, ie.y}, 0);
+ }
+ else if (ie.type == _EVENT_CHAR)
+ {
+ handler.charEvent(ie.c);
+ }
+ else if (ie.type == _EVENT_TERM)
+ {
+ return 0;
+ }
+
+ handler.write();
+ render.render();
+
+ usleep(10*1000);
+ }
+ }
+
+ /*cRender a(' ', _COL_DEFAULT, 20,20);
cInput in;
a.render();
@@ -53,7 +109,7 @@ int main()
usleep(10*1000);
}
- }
+ }*/
/*unsigned long int framecounter = 0;
cRender a(' ', _COL_DEFAULT, 10,10);