diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2019-03-20 16:46:36 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2019-03-20 16:46:36 +0100 |
commit | b1d1a78775ec913fb2b62c77ac56c47d8011f425 (patch) | |
tree | ceb36fe037181ff49061ce9b0f857e3f75befe15 /example | |
parent | 58f4e95113ecbb745161d5d520b4afb00b0e5abf (diff) | |
download | termgl-b1d1a78775ec913fb2b62c77ac56c47d8011f425.tar.gz |
example Pong is now screen size sensitive
Diffstat (limited to 'example')
-rw-r--r-- | example/pong.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/example/pong.cpp b/example/pong.cpp index 4524869..0783fcb 100644 --- a/example/pong.cpp +++ b/example/pong.cpp @@ -53,38 +53,41 @@ int main() cObjectHandler screen(&render); cInput input; + render.render(); + render.setTargetFPS(20); + + sPos size = render.getSize(); + bar barLeft; bar barRight; ball aball; - edge edgeLeft(1,30); - edge edgeRight(1,30); - edge edgeTop(100,1); - edge edgeBottom(100,1); + edge edgeLeft(1,size.y - 2); + edge edgeRight(1,size.y - 2); + edge edgeTop(size.x - 2,1); + edge edgeBottom(size.x - 2,1); int iEdgeTop = screen.createObject(&edgeTop); screen.moveObject(iEdgeTop, {0,0}, _MOVE_FORCE_ABSOLUTE); int iEdgeBottom = screen.createObject(&edgeBottom); - screen.moveObject(iEdgeBottom, {0,30}, _MOVE_FORCE_ABSOLUTE); + screen.moveObject(iEdgeBottom, {0,size.y - 3}, _MOVE_FORCE_ABSOLUTE); int iEdgeLeft = screen.createObject(&edgeLeft); screen.moveObject(iEdgeLeft, {0,0}, _MOVE_FORCE_ABSOLUTE); int iEdgeRight = screen.createObject(&edgeRight); - screen.moveObject(iEdgeRight, {99,0}, _MOVE_FORCE_ABSOLUTE); + screen.moveObject(iEdgeRight, {size.x - 2,0}, _MOVE_FORCE_ABSOLUTE); int iAball= screen.createObject(&aball); - screen.moveObject(iAball, {50,6}, _MOVE_FORCE_ABSOLUTE); + screen.moveObject(iAball, {size.x/2,size.y/2}, _MOVE_FORCE_ABSOLUTE); unsigned int iBarLeft = screen.createObject(&barLeft); screen.moveObject(iBarLeft, {10,4}, _MOVE_FORCE_ABSOLUTE); unsigned int iBarRight = screen.createObject(&barRight); - screen.moveObject(iBarRight, {90,4}, _MOVE_FORCE_ABSOLUTE); + screen.moveObject(iBarRight, {size.x - 10,4}, _MOVE_FORCE_ABSOLUTE); - render.render(); - render.setTargetFPS(20); unsigned int cc = 0; |