diff options
author | jonas <himself@jonasgunz.de> | 2018-12-10 21:08:33 +0100 |
---|---|---|
committer | jonas <himself@jonasgunz.de> | 2018-12-10 21:08:33 +0100 |
commit | 2da23ea7be6dd20da8d7319da4db69ff9688b9e6 (patch) | |
tree | f892f04c464daa17dff0497f52c525c63eb48ac0 /AmpelJonas | |
parent | 9fae9dfbc12525cdba4451d92f93c66bb6077b35 (diff) | |
download | termgl-2da23ea7be6dd20da8d7319da4db69ff9688b9e6.tar.gz |
modified the demo to not trap object outside of screen, changed makefile
Diffstat (limited to 'AmpelJonas')
-rw-r--r-- | AmpelJonas/Makefile | 4 | ||||
-rw-r--r-- | AmpelJonas/main.cpp | 17 |
2 files changed, 16 insertions, 5 deletions
diff --git a/AmpelJonas/Makefile b/AmpelJonas/Makefile index 539032f..c529a34 100644 --- a/AmpelJonas/Makefile +++ b/AmpelJonas/Makefile @@ -1,7 +1,7 @@ CC = /usr/bin/g++ CFLAGS = -Wall -g -LDFLAGS = -lm -lpthread -lcurses -OUTPUT = Kreuzung +LDFLAGS = -lm -lcurses +OUTPUT = Engine OBJ = main.o cObject.o cObjectHandler.o cRender.o diff --git a/AmpelJonas/main.cpp b/AmpelJonas/main.cpp index 343a688..d88ca9b 100644 --- a/AmpelJonas/main.cpp +++ b/AmpelJonas/main.cpp @@ -23,12 +23,23 @@ int main() b.write(); a.render(); - //usleep(10*1000); + usleep(10*1000); - if(x.getPosition().x <= 0 || x.getPosition().x >= a.getSize().x - 1) + if(x.getPosition().x <= 0) dir1 *= -1; - if(x.getPosition().y <= 0 || x.getPosition().y >= a.getSize().y) + else if(x.getPosition().x >= a.getSize().x) + { + dir1 *= -1; + x.setPosition({a.getSize().x, x.getPosition().y}); + } + + if(x.getPosition().y <= 0) + dir2 *= -1; + else if(x.getPosition().y >= a.getSize().y) + { dir2 *= -1; + x.setPosition({x.getPosition().x, a.getSize().y}); + } } a.render(); |