From 9cfee49590526bf675c169d79d72c9dc85bcfd7e Mon Sep 17 00:00:00 2001 From: brxxh <11dac2t@huhn-online.de> Date: Fri, 30 May 2025 17:27:11 +0200 Subject: [PATCH] Add tappyplane; Fix design problems TappyPlane is the new QuickWings using the Kenney assets --- examples/CMakeLists.txt | 2 +- examples/quickwings/CMakeLists.txt | 23 - examples/quickwings/assets/background-day.png | Bin 10361 -> 0 bytes examples/quickwings/assets/base.png | Bin 1963 -> 0 bytes examples/quickwings/assets/gameover.png | Bin 758 -> 0 bytes examples/quickwings/assets/message.png | Bin 1602 -> 0 bytes examples/quickwings/assets/pipe-green.png | Bin 2527 -> 0 bytes .../quickwings/assets/yellowbird-downflap.png | Bin 426 -> 0 bytes .../quickwings/assets/yellowbird-midflap.png | Bin 425 -> 0 bytes .../quickwings/assets/yellowbird-upflap.png | Bin 427 -> 0 bytes examples/quickwings/quickwings.cpp | 546 ------------------ examples/tappyplane/CMakeLists.txt | 18 + .../assets}/Font/kenvector_future.ttf | Bin .../assets}/Font/kenvector_future_thin.ttf | Bin .../assets}/PNG/Letters/letterA.png | Bin .../assets}/PNG/Letters/letterB.png | Bin .../assets}/PNG/Letters/letterC.png | Bin .../assets}/PNG/Letters/letterD.png | Bin .../assets}/PNG/Letters/letterE.png | Bin .../assets}/PNG/Letters/letterF.png | Bin .../assets}/PNG/Letters/letterG.png | Bin .../assets}/PNG/Letters/letterH.png | Bin .../assets}/PNG/Letters/letterI.png | Bin .../assets}/PNG/Letters/letterJ.png | Bin .../assets}/PNG/Letters/letterK.png | Bin .../assets}/PNG/Letters/letterL.png | Bin .../assets}/PNG/Letters/letterM.png | Bin .../assets}/PNG/Letters/letterN.png | Bin .../assets}/PNG/Letters/letterO.png | Bin .../assets}/PNG/Letters/letterP.png | Bin .../assets}/PNG/Letters/letterQ.png | Bin .../assets}/PNG/Letters/letterR.png | Bin .../assets}/PNG/Letters/letterS.png | Bin .../assets}/PNG/Letters/letterT.png | Bin .../assets}/PNG/Letters/letterU.png | Bin .../assets}/PNG/Letters/letterV.png | Bin .../assets}/PNG/Letters/letterW.png | Bin .../assets}/PNG/Letters/letterX.png | Bin .../assets}/PNG/Letters/letterY.png | Bin .../assets}/PNG/Letters/letterZ.png | Bin .../assets}/PNG/Numbers/number0.png | Bin .../assets}/PNG/Numbers/number1.png | Bin .../assets}/PNG/Numbers/number2.png | Bin .../assets}/PNG/Numbers/number3.png | Bin .../assets}/PNG/Numbers/number4.png | Bin .../assets}/PNG/Numbers/number5.png | Bin .../assets}/PNG/Numbers/number6.png | Bin .../assets}/PNG/Numbers/number7.png | Bin .../assets}/PNG/Numbers/number8.png | Bin .../assets}/PNG/Numbers/number9.png | Bin .../assets}/PNG/Planes/planeBlue1.png | Bin .../assets}/PNG/Planes/planeBlue2.png | Bin .../assets}/PNG/Planes/planeBlue3.png | Bin .../assets}/PNG/Planes/planeGreen1.png | Bin .../assets}/PNG/Planes/planeGreen2.png | Bin .../assets}/PNG/Planes/planeGreen3.png | Bin .../assets}/PNG/Planes/planeRed1.png | Bin .../assets}/PNG/Planes/planeRed2.png | Bin .../assets}/PNG/Planes/planeRed3.png | Bin .../assets}/PNG/Planes/planeYellow1.png | Bin .../assets}/PNG/Planes/planeYellow2.png | Bin .../assets}/PNG/Planes/planeYellow3.png | Bin .../assets}/PNG/UI/UIbg.png | Bin .../assets}/PNG/UI/buttonLarge.png | Bin .../assets}/PNG/UI/buttonSmall.png | Bin .../assets}/PNG/UI/medalBronze.png | Bin .../assets}/PNG/UI/medalGold.png | Bin .../assets}/PNG/UI/medalSilver.png | Bin .../assets}/PNG/UI/tap.png | Bin .../assets}/PNG/UI/tapLeft.png | Bin .../assets}/PNG/UI/tapRight.png | Bin .../assets}/PNG/UI/tapTick.png | Bin .../assets}/PNG/UI/textGameOver.png | Bin .../assets}/PNG/UI/textGetReady.png | Bin .../assets}/PNG/background.png | Bin .../assets}/PNG/groundDirt.png | Bin .../assets}/PNG/groundGrass.png | Bin .../assets}/PNG/groundIce.png | Bin .../assets}/PNG/groundRock.png | Bin .../assets}/PNG/groundSnow.png | Bin .../assets}/PNG/puffLarge.png | Bin .../assets}/PNG/puffSmall.png | Bin .../assets}/PNG/rock.png | Bin .../assets}/PNG/rockDown.png | Bin .../assets}/PNG/rockGrass.png | Bin .../assets}/PNG/rockGrassDown.png | Bin .../assets}/PNG/rockIce.png | Bin .../assets}/PNG/rockIceDown.png | Bin .../assets}/PNG/rockSnow.png | Bin .../assets}/PNG/rockSnowDown.png | Bin .../assets}/PNG/starBronze.png | Bin .../assets}/PNG/starGold.png | Bin .../assets}/PNG/starSilver.png | Bin .../assets}/Spritesheet/planes.png | Bin .../assets}/Spritesheet/planes.xml | 0 .../assets}/Spritesheet/sheet.png | Bin .../assets}/Spritesheet/sheet.xml | 0 .../assets}/Vector/vector.svg | 0 .../assets}/Vector/vector.swf | Bin .../assets}/license.txt | 0 .../assets}/preview.png | Bin .../assets}/sample.png | Bin 81791 -> 81792 bytes examples/tappyplane/tappyplane.cpp | 456 +++++++++++++++ 103 files changed, 475 insertions(+), 570 deletions(-) delete mode 100644 examples/quickwings/CMakeLists.txt delete mode 100644 examples/quickwings/assets/background-day.png delete mode 100644 examples/quickwings/assets/base.png delete mode 100644 examples/quickwings/assets/gameover.png delete mode 100644 examples/quickwings/assets/message.png delete mode 100644 examples/quickwings/assets/pipe-green.png delete mode 100644 examples/quickwings/assets/yellowbird-downflap.png delete mode 100644 examples/quickwings/assets/yellowbird-midflap.png delete mode 100644 examples/quickwings/assets/yellowbird-upflap.png delete mode 100644 examples/quickwings/quickwings.cpp create mode 100644 examples/tappyplane/CMakeLists.txt rename examples/{quickwings/assets/tappybird => tappyplane/assets}/Font/kenvector_future.ttf (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/Font/kenvector_future_thin.ttf (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterA.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterB.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterC.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterD.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterE.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterF.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterG.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterH.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterI.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterJ.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterK.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterL.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterM.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterN.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterO.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterP.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterQ.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterR.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterS.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterT.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterU.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterV.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterW.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterX.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterY.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Letters/letterZ.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number0.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number1.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number2.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number3.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number4.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number5.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number6.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number7.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number8.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Numbers/number9.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeBlue1.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeBlue2.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeBlue3.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeGreen1.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeGreen2.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeGreen3.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeRed1.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeRed2.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeRed3.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeYellow1.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeYellow2.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/Planes/planeYellow3.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/UIbg.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/buttonLarge.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/buttonSmall.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/medalBronze.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/medalGold.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/medalSilver.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/tap.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/tapLeft.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/tapRight.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/tapTick.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/textGameOver.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/UI/textGetReady.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/background.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/groundDirt.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/groundGrass.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/groundIce.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/groundRock.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/groundSnow.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/puffLarge.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/puffSmall.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/rock.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/rockDown.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/rockGrass.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/rockGrassDown.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/rockIce.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/rockIceDown.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/rockSnow.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/rockSnowDown.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/starBronze.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/starGold.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/PNG/starSilver.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/Spritesheet/planes.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/Spritesheet/planes.xml (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/Spritesheet/sheet.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/Spritesheet/sheet.xml (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/Vector/vector.svg (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/Vector/vector.swf (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/license.txt (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/preview.png (100%) rename examples/{quickwings/assets/tappybird => tappyplane/assets}/sample.png (99%) create mode 100644 examples/tappyplane/tappyplane.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9d4c49a..713b59e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(simple) add_subdirectory(pong) -add_subdirectory(quickwings) \ No newline at end of file +add_subdirectory(tappyplane) diff --git a/examples/quickwings/CMakeLists.txt b/examples/quickwings/CMakeLists.txt deleted file mode 100644 index 5ac3667..0000000 --- a/examples/quickwings/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -set(quickwings_srcs quickwings.cpp) -set(quickwings_assets - assets/background-day.png - assets/base.png - assets/pipe-green.png - assets/yellowbird-downflap.png - assets/yellowbird-midflap.png - assets/yellowbird-upflap.png - ) - -set_source_files_properties(${quickwings_assets} PROPERTIES HEADER_FILE_ONLY TRUE) - -add_executable(quickwings ${quickwings_srcs} ${quickwings_assets}) - -target_link_libraries(quickwings paradiso_core) - -# -# copy files to bin/../assets folder -# -add_custom_command(TARGET quickwings POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/assets/ - $/assets) diff --git a/examples/quickwings/assets/background-day.png b/examples/quickwings/assets/background-day.png deleted file mode 100644 index f9ed139c84f87b86b0ea31e47c729fde44f8b70d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10361 zcmeHtXIB$i&~88w1S#qPJyHcZAcz&E6O<-RR18ShqYxq>V(5?rY;+>h1Oq{O3qh*1 z1QkSS37|j-Axevs5E3AiB;<1Ly+7go_WEIe*n6#6d#{;ip8d?MNw{&{N&x+`kV1XrzUt5wwKv9qR$M#hi?6mwtim^Y7F+2h}DKShl7XrBND z?%c-m8N3#iq%6OyrDV%@vU*6&Bx? z1HBL=-EVc_b`j+2>3CJ!>+KzdS;bXqmsDHT9P&Y#9EK64pLmzpaY`}-iQ^xCwiB>5 z!Qv6jsCc8k32czDSs4gJPz~^F9MDoWkmL1Cf7c8kAS5U>zwgU~YeLed zcQs4}Rivd&mF;4L{<0)=iYo8z_y5`d@y8!L{KL2JNuJG$TwwG%Z8zBbLM=jaT@TDBu8sKW_Q6U8b4&h#orvkg36;mNyDetYH4DVR zQ~aUa=GWkFQXi8%1+*U+j<3;pqO2fk=CHcG3?brd(4h7mwY7J;CgG|`QoWGZn7bTKNCB(1^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Uk9Al~`aQKGWomLA#Y#rc0xxcx%kaYP;Q^86h+vdF*P*zzWGsQO+ zAebq1%{24wf~zYp&jX`hNgJt<;$S diff --git a/examples/quickwings/assets/base.png b/examples/quickwings/assets/base.png deleted file mode 100644 index 26fa39129aa33fe2b906d9b77751651fee1a2272..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1963 zcmeAS@N?(olHy`uVBq!ia0y~yVEh4O7jUov$xnNd>VN`yna<7unaRlv3>p(lC)#=+ z4iIUZALhETtBKE5#wesPBT(c>;OhrLORjL$>E`A{E$mdxocKs;J$1i)nn?v$}b`YemTRxlJ2O0S* zx2*m*aWO(Zg09NG6GcCXba-r4*}T8j*?wPU*wMwOZ!c?6?$fdS*ygJ1b-gFV`Ad&Y zrI*(C`<1(nohVpZ9W63T&i4IQ{#n}}u6|QFzkS~KQWjqRg1oDLR!_QoWA}@vv&3$- z_wicnU6J`x*5Y={gS~T$g6xBubM_}5IL*1`yz_O_EqY;_R?RD}VLw^=(=~jyk%O;PHSfSq=|b^!PEybFoTr4H+OtG!Y2&-LKR@Rz`846h&v&_g^Mtp* zkK6li=f`daMkW>x0S`_aucd-*5Y7+X4S)YVo-Dm5Rl%VFC}hZJ{^N$jQAIFkJJW6c z__#Tx&Gp~D{ERFzzrSzZ*Wb1OtinJKhO9c6SiA??9b1IHFq97|K(FrE zDEFVwZ12-{*(KZ6xHY!_O0)YnGyD9vV&C-54-cn{toZw9*TMeFUwuFhWKm*L&;PLR z<~siw{PP1Bd^=lzX4{vX|I$jW#+KXA%oPU1d@ekSg$rBHM{|>aG{>2+vNRV>8dG~tu;U$kht9L#Pw>zzOS#!Q; z($A^qH=Qmyl|Ct=?&;FyCqj5=tbWPD3CqYnvZRLI=x4)+NE!!tyP_#A90m|hq zVFJl9G@f-kc$*0v4FVzo9}X_;f&_!e9$AnyBav~=QQY`6?zK#qG8~eHcB(ehe3dtTp zz6=aistgPb%?u1b{{!il3=E|P3=FRl7#OT(0Cnb1ia+WGRBI666XN>+KTrui5MtpD zL_lSK7I-{KkT{)kY#vZKPf3tpFwlA?HfDB44p#0zv)_qt0E#mvdAqwXbg;^L06Clm z9+AZi4BWyX%*Zfnjs#GUy~NYkmHja@4+E3%^IxhvfO@8Rx;Tb-9KSmKVD4c99@ni- z6IhviFD!5n&tUW5pQ+GrG24IE0*Ai6X|3ym)-4d-(xeqFXn{4@1l2{lx8d|iC} zkYKRyDWm<|FFuJ}t9rC^!>{QK4!%0C_*=p+*QX@Q8NAMrYM7qS=$9^Qwf?+pTIsI| zCGtVCjI$QCr5u>jz3JY^c_IhCZ`zXJ&A6fT0E68$WkKP!K@C=i3qLkKP;jW-pxkV6 zz?bQSrNym=jgA5V*M2e{xG(ZRiXrZawnOAgF@|`zH@~7B{=7TI{HpTWi=PdjLO+T# z4oU-o9h?Opt8>ukAa*&$cI$lNeYxFSSTa(s+Mk@;w!X`6s)5n8c(H zn*t+EwZt`|BqgyV)hf9t6-Y4{85mmX8W`&u8ip8JSQ!{u8Cq%^m{}PZJk+v0jG`eo aKP5A*61Rp4<&E_~4Gf;HelF{r5}E*LS`Uf< diff --git a/examples/quickwings/assets/message.png b/examples/quickwings/assets/message.png deleted file mode 100644 index 9243ab58b2910ae63393eb28ac5867237826d7e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1602 zcmZ{kdpOg39LIldIW|ifigMOTTMu)YOPX;kovjgbzqjPBo3RiTT`cC3OLY=0TXb=Y zmBic&vucSriOh8gtz-$C)XuLz&mZUeJm2T_d4Im2_xE}K@qNCT?ye*lL=OT00L;me z;0clo018lLC9o>A@?e5cj&dM70KmgM=vs&hsJDeVdXfR)G!g*L(*Zyx2RR1-2^awQ z7z_ZoLIBtlbL9|kA2_?i-Nl;-QZ5Ilel2e-X?1lKl>S5hK)K`K;GpMjqTCSnWz$Ym z@K`zC)71+Mpw0Jr1l|WIggTQ53UWo0F;J+*ItIi602KafD*!icZU&pG@lIr-sz^y4 zP=wE{BEj^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PC diff --git a/examples/quickwings/assets/yellowbird-midflap.png b/examples/quickwings/assets/yellowbird-midflap.png deleted file mode 100644 index 2ca3c2d034b2332726bb6157591ee3319900c2fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 425 zcmeAS@N?(olHy`uVBq!ia0vp^N0k@DU)Otn z{rdG|yYcmBXZ~0)JZRAQ|NsAjlBe20X~vQuzhDN3XE)M7oFs2|7ml`jQ>%a+&H|6f zVg?3oVGw3ym^DWND9B#o>Fdh=n3;!xN%;9M)g3^gOivfb5Q)pJ7ccT2P~cz*2-_hV zaZog3q4tiZ*WX=k-CFeW?_KXB9ZGT)DW}32LR~d)aPO9UxKJfwxlGFf6@%Z?=Pl^{ zvG%BD+$I544c4p8tvx5#F1#mwQfZCt4!*T6202kV(`MNHKjQ6|w8gBn>)PVeKuc9i zTq8@t-i!lHI diff --git a/examples/quickwings/assets/yellowbird-upflap.png b/examples/quickwings/assets/yellowbird-upflap.png deleted file mode 100644 index 2f693da65360f492a3b364b2231c4419d9c782af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 427 zcmeAS@N?(olHy`uVBq!ia0vp^N0k@DU)Otn z{rdG|yYcmBXZ~0)JZRAQ|NsAjlBe20X~vQuzhDN3XE)M7oFs2|7ml`jQ>%a+&H|6f zVg?3oVGw3ym^DWND9B#o>Fdh=n3;!xN%;9M)g3^gY)==*5Q)pZ7b67^DDbdch=}0c z*w7lWf>q~8UGW7c%d}nbAJ~jk1Y89cDsE;t(-Tx6cDq}mWY$sdu9K+~ws_3@r^r9I zCHG+9?$S+MuIzlKO>=(;hl+0XPf?aSSe>cdvL$iD>MaNR?LSVG4zn=ZxrY0iGSFJp z64!{5l*E!$tK_0oAjM#0U}&jpV61Cs7-DE)Wng4wXsK;rW@TXTP|NZ#iiX_$l+3hB W+!`j7H`W6+FnGH9xvX -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// TODO remove all hard coded 'magic' values! - -// TODO - remove global variables -const int frame_rate = 60; -bool game_over = false; -float risky_pos_x; -float risky_pos_max_x; -float risky_pos_bottom_y; -float risky_pos_top_y; -float risky_pos_bottom_max_y; -float risky_pos_top_max_y; - -struct Background { - paradiso::Sprite backgroundLeft; - paradiso::Sprite backgroundRight; - paradiso::Sprite grassLeft; - paradiso::Sprite grassRight; - - paradiso::Sprite* scrolling[2] = {&backgroundLeft, &backgroundRight}; - - paradiso::Renderer renderer{}; - - // TODO no constructors in rule of zero - Background() { - auto backgroundImage = - paradiso::BitmapIO::get().load("background-day.png"); - backgroundLeft = paradiso::Sprite{ - .bitmap = backgroundImage, - .pivot = {paradiso::Vector2::make(0.0f, 0.16f)}, - .scale = {paradiso::Vector2::make(1.01f, 1.3f)}}; - backgroundRight = paradiso::Sprite{ - .bitmap = backgroundImage, - .pivot = {paradiso::Vector2::make(2.018f, 0.16f)}, - .scale = {paradiso::Vector2::make(1.01f, 1.3f)}}; - - auto grassImage = paradiso::BitmapIO::get().load("base.png"); - grassLeft = paradiso::Sprite{ - .bitmap = grassImage, - .pivot = {paradiso::Vector2::make(0.0f, -1.0f)}, - .scale = {paradiso::Vector2::make(1.0f, 0.33333f)}}; - grassRight = paradiso::Sprite{ - .bitmap = grassImage, - .pivot = {paradiso::Vector2::make(2.0f, -1.0f)}, - .scale = {paradiso::Vector2::make(1.0f, 0.33333f)}}; - } - - void draw(const paradiso::Shader& shader) { - for (auto sprite : scrolling) { - if (game_over == false) { - if (sprite->pivot.x() <= -2.0f) { - sprite->pivot.x() += 4.0f; - } - sprite->pivot.x() -= 0.002f; - } - shader.set_uniform("pivot", sprite->pivot); - shader.set_uniform("scale", sprite->scale); - shader.set_uniform("rotation", sprite->rotation); - renderer.draw(*sprite, shader); - } - } -}; - -struct Pipe { - paradiso::Sprite pipe_top{}; - paradiso::Sprite pipe_bottom{}; - - paradiso::Renderer renderer1{}; - paradiso::Renderer renderer2{}; - - bool paused = false; - - int pipe_spawn_rand_int = rand() % 80 + 15; - float pipe_spawn_rand = float(pipe_spawn_rand_int) / 100; - - bool pos_reset = false; - - // TODO no constructors in rule of zero - - Pipe() { - auto pipe_image = paradiso::BitmapIO::get().load("pipe-green.png"); - - pipe_top = paradiso::Sprite{ - .bitmap = pipe_image, - .pivot = {paradiso::Vector2::make(1.4f, - pipe_spawn_rand + 1.0f)}, - .scale = {paradiso::Vector2::make( - ((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, - ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)}, - .rotation = 3.1415926f}; - pipe_bottom = paradiso::Sprite{ - .bitmap = pipe_image, - .pivot = {paradiso::Vector2::make(1.4f, - pipe_spawn_rand - 1.5f)}, - .scale = {paradiso::Vector2::make( - ((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, - ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)}}; - - paused = true; - } - - void update() { - - // TODO improve state handling - - if (game_over == true) { - paused = true; - } - - if (paused == true) { - return; - } else { - pipe_spawn_rand_int = rand() % 80 + 15; - pipe_spawn_rand = float(pipe_spawn_rand_int) / 100; - - pipe_top.pivot.x() -= 0.02f; - pipe_bottom.pivot.x() -= 0.02f; - - risky_pos_x = pipe_top.pivot.x(); - risky_pos_max_x = pipe_top.pivot.x() + - ((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f; - - risky_pos_top_y = pipe_top.pivot.y(); - risky_pos_top_max_y = pipe_top.pivot.y() + 10.0f; - - risky_pos_bottom_y = pipe_bottom.pivot.y(); - risky_pos_bottom_max_y = pipe_bottom.pivot.y() - 10.0f; - - if (pipe_top.pivot.x() <= -1.4f || pipe_bottom.pivot.x() <= -1.4f) { - pos_reset = true; - - if (pos_reset == true) { - pipe_top.pivot.y() = pipe_spawn_rand + 1.0f; - pipe_bottom.pivot.y() = pipe_spawn_rand - 1.5; - - pos_reset = false; - } - - pipe_top.pivot.x() = 1.4f; - pipe_bottom.pivot.x() = 1.4f; - } - } - } - - void draw(const paradiso::Shader& shader) { - shader.set_uniform("pivot", pipe_bottom.pivot); - shader.set_uniform("scale", pipe_bottom.scale); - renderer1.draw(pipe_bottom, shader); - - shader.set_uniform("pivot", pipe_top.pivot); - shader.set_uniform("scale", pipe_top.scale); - shader.set_uniform("rotation", pipe_top.rotation); - renderer1.draw(pipe_top, shader); - } -}; - -struct Grass { - paradiso::Sprite grassLeft; - paradiso::Sprite grassRight; - paradiso::Sprite* scrolling[2] = {&grassLeft, &grassRight}; - - paradiso::Renderer renderer1{}; - paradiso::Renderer renderer2{}; - - // TODO no constructors in rule of zero - Grass() { - auto grassImage = paradiso::BitmapIO::get().load("base.png"); - grassLeft = paradiso::Sprite{ - .bitmap = grassImage, - .pivot = {paradiso::Vector2::make(0.0f, -0.9f)}, - .scale = {paradiso::Vector2::make( - ((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, - ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}}; - grassRight = paradiso::Sprite{ - .bitmap = grassImage, - .pivot = {paradiso::Vector2::make(1.002f, -0.9f)}, - .scale = {paradiso::Vector2::make( - ((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, - ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}}; - } - - void draw(const paradiso::Shader& shader) { - if (game_over == false) { - grassLeft.pivot.x() -= 0.02f; - grassRight.pivot.x() -= 0.02f; - - if (grassRight.pivot.x() <= 0.0f) { - grassLeft.pivot.x() = 1.002f; - } - if (grassRight.pivot.x() <= -1.002f) { - grassRight.pivot.x() = 1.002f; - } - } - - shader.set_uniform("pivot", grassLeft.pivot); - shader.set_uniform("scale", grassLeft.scale); - shader.set_uniform("rotation", grassLeft.rotation); - - shader.set_uniform("pivot", grassRight.pivot); - shader.set_uniform("scale", grassRight.scale); - shader.set_uniform("rotation", grassRight.rotation); - - renderer1.draw(grassLeft, shader); - renderer2.draw(grassRight, shader); - } -}; - -struct QuickWings { - paradiso::Renderer renderer1{}; - paradiso::Renderer renderer2{}; - paradiso::Renderer renderer3{}; - - std::array birds; - unsigned int flap = 0; - unsigned int flapSpeed = 15; // How many ticks per flap - unsigned int flapCounter = 0; // How many ticks since last flap - - float velocity = 0.0f; - const float max_velocity = 0.02f; - - const float gravity = -0.002f; - const float move_up_velocity = 0.02f; - - bool move_up = false; - bool paused = true; - - const float max_pos = 0.95f; - const float min_pos = -0.5f; - - float pos = 0.34f; - - float rotation = 0.0f; - - int collision_counter = 0; - - // TODO no constructors in rule of zero - QuickWings() { - float scaleh = 0.08f; - float scalew = 0.158f; - - birds = { - paradiso::Sprite{ - .bitmap = - paradiso::BitmapIO::get().load("yellowbird-downflap.png"), - .pivot = {paradiso::Vector2::make(0.0f, 0.0f)}, - .scale = {paradiso::Vector2::make(scalew, scaleh)}}, - paradiso::Sprite{ - .bitmap = - paradiso::BitmapIO::get().load("yellowbird-midflap.png"), - .pivot = {paradiso::Vector2::make(0.0f, 0.0f)}, - .scale = {paradiso::Vector2::make(scalew, scaleh)}}, - paradiso::Sprite{ - .bitmap = - paradiso::BitmapIO::get().load("yellowbird-upflap.png"), - .pivot = {paradiso::Vector2::make(0.0f, 0.0f)}, - .scale = {paradiso::Vector2::make(scalew, scaleh)}}}; - } - - void draw(const paradiso::Shader& shader) { - // Update flap state - if (flapCounter < flapSpeed) { - flapCounter++; - } else { - flapCounter = 0; - flap = (flap + 1) % birds.size(); - } - - auto bird = birds[flap]; - bird.pivot.y() = pos; - bird.rotation = rotation; - shader.set_uniform("pivot", bird.pivot); - shader.set_uniform("scale", bird.scale); - shader.set_uniform("rotation", bird.rotation); - - switch (flap) { - case 0: - renderer1.draw(bird, shader); - break; - case 1: - renderer2.draw(bird, shader); - break; - case 2: - renderer3.draw(bird, shader); - break; - } - } - - void update() { - - if (game_over == true) { - paused = true; - } - - // Stop game - if (paused) { - return; - } else { - // Apply gravity - velocity += gravity; - - if (move_up) - velocity += move_up_velocity - gravity; - - // Cap velocity - if (velocity > max_velocity) - velocity = max_velocity; - if (velocity < -max_velocity) - velocity = -max_velocity; - - // Cap position - pos += velocity; - if (pos < min_pos) { - pos = min_pos; - velocity = 0.0f; - game_over = true; - } - if (pos > max_pos) { - pos = max_pos; - velocity = 0.0f; - game_over = true; - } - - // Update rotation - rotation = velocity * 10.0f; - } - - float final_risky_pos_top_y = risky_pos_top_y - 1.06f; - float final_risky_pos_bottom_y = risky_pos_bottom_y + 1.06f; - - if (risky_pos_x - 0.3f <= 0.0f && risky_pos_max_x >= 0.0f) { - if (pos >= final_risky_pos_top_y && pos <= risky_pos_top_max_y) { - game_over = true; - } - if (pos <= final_risky_pos_bottom_y && - pos >= risky_pos_bottom_max_y) { - if (collision_counter == 0) { - collision_counter++; - } else { - collision_counter = 2; - } - - if (collision_counter == 2) { - game_over = true; - } - } - } - } - - // keyboard handler - void on_keyboard(const paradiso::Window::KeyboardInputStack& input) { - if (input.size()) { - paused = false; - - if (paused == false) { - bool pressed_up = - input.top().key == ' ' || input.top().key == 'W'; - - if (input.top().action == 1 && pressed_up) { - move_up = true; - } else if (input.top().action == 0 && pressed_up) { - move_up = false; - } - } else { - return; - } - } - } -}; - -struct Message { - paradiso::Sprite messageSprite; - paradiso::Renderer renderer{}; - bool start = false; - float pos = 100.0f; - - Message() { - auto messageImage = paradiso::BitmapIO::get().load("message.png"); - messageSprite = paradiso::Sprite{ - .bitmap = messageImage, - .pivot = {paradiso::Vector2::make(0.0f, 0.0f)}, - .scale = {paradiso::Vector2::make(0.8f, 0.8f)}}; - }; - - void draw(const paradiso::Shader& shader) { - shader.set_uniform("pivot", messageSprite.pivot); - shader.set_uniform("scale", messageSprite.scale); - renderer.draw(messageSprite, shader); - } - - void update() { - if (start == true) { - messageSprite.pivot.y() = pos; - } - } - - void on_keyboard(const paradiso::Window::KeyboardInputStack& input) { - if (input.size()) { - start = true; - } - } -}; - -struct GameOverMessage { - paradiso::Sprite messageSprite; - paradiso::Renderer renderer{}; - - GameOverMessage() { - auto messageImage = paradiso::BitmapIO::get().load("gameover.png"); - messageSprite = paradiso::Sprite{ - .bitmap = messageImage, - .pivot = {paradiso::Vector2::make(0.0f, 0.4f)}, - .scale = {paradiso::Vector2::make( - ((500.0f - (500.0f - 192.0f)) / 500.0f) * 2.25f, - ((700.0f - (700.0f - 42.0f)) / 700.0f) * 2.25f)}}; - }; - - void draw(const paradiso::Shader& shader) { - shader.set_uniform("pivot", messageSprite.pivot); - shader.set_uniform("scale", messageSprite.scale); - renderer.draw(messageSprite, shader); - } -}; - -auto main() -> int { - std::srand(std::time(nullptr)); - - // Ausgabefenster ... sieht aus als wäre es auf dem Stack - auto window = paradiso::Window(); - - auto size = paradiso::Size{.width = 500, .height = 700}; - - /* - window.set_resizecallback([](auto& w) -> void { - w.set_size(paradiso::Size{.width = 405, .height = 720}); - }); - -*/ - window - .set_size(size) // ... Grösse - .set_position(paradiso::Point{.x = 1920 / 2 - 500 / 2, - .y = 1080 / 2 - 700 / 2}) // ... Position - .set_title("PardiSO.FlappyBird") // ... Titel - .set_visible(true); // ... und jetzt anzeigen! - - // der Fenster Kontext - auto ctx = paradiso::Context{}; - - // ein Shader (Schattierungsprogramm) - auto shader = paradiso::Shader{}; - - // wir nutzen einen vorgefertigten shader - shader.load_preset(paradiso::Shader::Preset::Sprite); - - // ein viewport stellt die Sicht der Kamera dar, d.h. bei quadratischen - // Pixeln sollte hier auch eine dementsprechende Grösse eingestellt - // werden - ctx.set_viewport(paradiso::Rectangle{ - .position = paradiso::Point{.x = 0, .y = 0}, .size = size}); - - // nothing beats a classic look - ctx.set_clearcolor(paradiso::RGBA::from_rgb(0x00, 0x00, 0x00)); - - // Asset loader bekommt den Pfad - - paradiso::BitmapIO::get().set_path("assets"); - - // Load - auto background = Background{}; - auto grass = Grass{}; - auto quickwingsapp = QuickWings{}; - auto pipe = Pipe{}; - auto message = Message{}; - auto gameover = GameOverMessage{}; - - // timer - - // das update führt den hier mitgegebnen Ausdruck innerhalb der internen - // Updates des Fensters auf. Es wird hier auch explizit ein bool gefordert - // damit das update auch zu jederzeit unterbrochen werden kann - while (window.update([&](paradiso::Window& w) -> bool { - ctx.set_viewport(paradiso::Rectangle{ - .position = paradiso::Point{.x = 0, .y = 0}, .size = size}); - - ctx.clear(); - auto t1 = std::chrono::high_resolution_clock::now(); - - // Keyboard and state change + update - if (quickwingsapp.paused == false) { - pipe.paused = false; - } - - pipe.update(); - - quickwingsapp.on_keyboard(w.keyboard_input()); - quickwingsapp.update(); - - message.on_keyboard(w.keyboard_input()); - message.update(); - - // Draw - background.draw(shader); - pipe.draw(shader); - grass.draw(shader); - message.draw(shader); - - if (game_over == true) { - gameover.draw(shader); - } - - quickwingsapp.draw(shader); - - // wait for frame rate - auto t2 = std::chrono::high_resolution_clock::now(); - auto duration = - std::chrono::duration_cast(t2 - t1); - auto wait = std::chrono::microseconds(1000000 / frame_rate) - duration; - std::this_thread::sleep_for(wait); - - // Quit - return !(w.keyboard_input().size() && - w.keyboard_input().top().key == 'Q'); - })) { - }; - - return 0; -} diff --git a/examples/tappyplane/CMakeLists.txt b/examples/tappyplane/CMakeLists.txt new file mode 100644 index 0000000..7d4f40a --- /dev/null +++ b/examples/tappyplane/CMakeLists.txt @@ -0,0 +1,18 @@ +set(tappyplane_srcs tappyplane.cpp) +set(tappyplane_assets + assets/PNG/background.png + ) + +set_source_files_properties(${tappyplane_assets} PROPERTIES HEADER_FILE_ONLY TRUE) + +add_executable(tappyplane ${tappyplane_srcs} ${tappyplane_assets}) + +target_link_libraries(tappyplane paradiso_core) + +# +# copy files to bin/../assets folder +# +add_custom_command(TARGET tappyplane POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/assets/ + $/assets) diff --git a/examples/quickwings/assets/tappybird/Font/kenvector_future.ttf b/examples/tappyplane/assets/Font/kenvector_future.ttf similarity index 100% rename from examples/quickwings/assets/tappybird/Font/kenvector_future.ttf rename to examples/tappyplane/assets/Font/kenvector_future.ttf diff --git a/examples/quickwings/assets/tappybird/Font/kenvector_future_thin.ttf b/examples/tappyplane/assets/Font/kenvector_future_thin.ttf similarity index 100% rename from examples/quickwings/assets/tappybird/Font/kenvector_future_thin.ttf rename to examples/tappyplane/assets/Font/kenvector_future_thin.ttf diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterA.png b/examples/tappyplane/assets/PNG/Letters/letterA.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterA.png rename to examples/tappyplane/assets/PNG/Letters/letterA.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterB.png b/examples/tappyplane/assets/PNG/Letters/letterB.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterB.png rename to examples/tappyplane/assets/PNG/Letters/letterB.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterC.png b/examples/tappyplane/assets/PNG/Letters/letterC.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterC.png rename to examples/tappyplane/assets/PNG/Letters/letterC.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterD.png b/examples/tappyplane/assets/PNG/Letters/letterD.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterD.png rename to examples/tappyplane/assets/PNG/Letters/letterD.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterE.png b/examples/tappyplane/assets/PNG/Letters/letterE.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterE.png rename to examples/tappyplane/assets/PNG/Letters/letterE.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterF.png b/examples/tappyplane/assets/PNG/Letters/letterF.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterF.png rename to examples/tappyplane/assets/PNG/Letters/letterF.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterG.png b/examples/tappyplane/assets/PNG/Letters/letterG.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterG.png rename to examples/tappyplane/assets/PNG/Letters/letterG.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterH.png b/examples/tappyplane/assets/PNG/Letters/letterH.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterH.png rename to examples/tappyplane/assets/PNG/Letters/letterH.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterI.png b/examples/tappyplane/assets/PNG/Letters/letterI.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterI.png rename to examples/tappyplane/assets/PNG/Letters/letterI.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterJ.png b/examples/tappyplane/assets/PNG/Letters/letterJ.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterJ.png rename to examples/tappyplane/assets/PNG/Letters/letterJ.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterK.png b/examples/tappyplane/assets/PNG/Letters/letterK.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterK.png rename to examples/tappyplane/assets/PNG/Letters/letterK.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterL.png b/examples/tappyplane/assets/PNG/Letters/letterL.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterL.png rename to examples/tappyplane/assets/PNG/Letters/letterL.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterM.png b/examples/tappyplane/assets/PNG/Letters/letterM.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterM.png rename to examples/tappyplane/assets/PNG/Letters/letterM.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterN.png b/examples/tappyplane/assets/PNG/Letters/letterN.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterN.png rename to examples/tappyplane/assets/PNG/Letters/letterN.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterO.png b/examples/tappyplane/assets/PNG/Letters/letterO.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterO.png rename to examples/tappyplane/assets/PNG/Letters/letterO.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterP.png b/examples/tappyplane/assets/PNG/Letters/letterP.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterP.png rename to examples/tappyplane/assets/PNG/Letters/letterP.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterQ.png b/examples/tappyplane/assets/PNG/Letters/letterQ.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterQ.png rename to examples/tappyplane/assets/PNG/Letters/letterQ.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterR.png b/examples/tappyplane/assets/PNG/Letters/letterR.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterR.png rename to examples/tappyplane/assets/PNG/Letters/letterR.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterS.png b/examples/tappyplane/assets/PNG/Letters/letterS.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterS.png rename to examples/tappyplane/assets/PNG/Letters/letterS.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterT.png b/examples/tappyplane/assets/PNG/Letters/letterT.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterT.png rename to examples/tappyplane/assets/PNG/Letters/letterT.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterU.png b/examples/tappyplane/assets/PNG/Letters/letterU.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterU.png rename to examples/tappyplane/assets/PNG/Letters/letterU.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterV.png b/examples/tappyplane/assets/PNG/Letters/letterV.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterV.png rename to examples/tappyplane/assets/PNG/Letters/letterV.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterW.png b/examples/tappyplane/assets/PNG/Letters/letterW.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterW.png rename to examples/tappyplane/assets/PNG/Letters/letterW.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterX.png b/examples/tappyplane/assets/PNG/Letters/letterX.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterX.png rename to examples/tappyplane/assets/PNG/Letters/letterX.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterY.png b/examples/tappyplane/assets/PNG/Letters/letterY.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterY.png rename to examples/tappyplane/assets/PNG/Letters/letterY.png diff --git a/examples/quickwings/assets/tappybird/PNG/Letters/letterZ.png b/examples/tappyplane/assets/PNG/Letters/letterZ.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Letters/letterZ.png rename to examples/tappyplane/assets/PNG/Letters/letterZ.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number0.png b/examples/tappyplane/assets/PNG/Numbers/number0.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number0.png rename to examples/tappyplane/assets/PNG/Numbers/number0.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number1.png b/examples/tappyplane/assets/PNG/Numbers/number1.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number1.png rename to examples/tappyplane/assets/PNG/Numbers/number1.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number2.png b/examples/tappyplane/assets/PNG/Numbers/number2.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number2.png rename to examples/tappyplane/assets/PNG/Numbers/number2.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number3.png b/examples/tappyplane/assets/PNG/Numbers/number3.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number3.png rename to examples/tappyplane/assets/PNG/Numbers/number3.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number4.png b/examples/tappyplane/assets/PNG/Numbers/number4.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number4.png rename to examples/tappyplane/assets/PNG/Numbers/number4.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number5.png b/examples/tappyplane/assets/PNG/Numbers/number5.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number5.png rename to examples/tappyplane/assets/PNG/Numbers/number5.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number6.png b/examples/tappyplane/assets/PNG/Numbers/number6.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number6.png rename to examples/tappyplane/assets/PNG/Numbers/number6.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number7.png b/examples/tappyplane/assets/PNG/Numbers/number7.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number7.png rename to examples/tappyplane/assets/PNG/Numbers/number7.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number8.png b/examples/tappyplane/assets/PNG/Numbers/number8.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number8.png rename to examples/tappyplane/assets/PNG/Numbers/number8.png diff --git a/examples/quickwings/assets/tappybird/PNG/Numbers/number9.png b/examples/tappyplane/assets/PNG/Numbers/number9.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Numbers/number9.png rename to examples/tappyplane/assets/PNG/Numbers/number9.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeBlue1.png b/examples/tappyplane/assets/PNG/Planes/planeBlue1.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeBlue1.png rename to examples/tappyplane/assets/PNG/Planes/planeBlue1.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeBlue2.png b/examples/tappyplane/assets/PNG/Planes/planeBlue2.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeBlue2.png rename to examples/tappyplane/assets/PNG/Planes/planeBlue2.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeBlue3.png b/examples/tappyplane/assets/PNG/Planes/planeBlue3.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeBlue3.png rename to examples/tappyplane/assets/PNG/Planes/planeBlue3.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeGreen1.png b/examples/tappyplane/assets/PNG/Planes/planeGreen1.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeGreen1.png rename to examples/tappyplane/assets/PNG/Planes/planeGreen1.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeGreen2.png b/examples/tappyplane/assets/PNG/Planes/planeGreen2.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeGreen2.png rename to examples/tappyplane/assets/PNG/Planes/planeGreen2.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeGreen3.png b/examples/tappyplane/assets/PNG/Planes/planeGreen3.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeGreen3.png rename to examples/tappyplane/assets/PNG/Planes/planeGreen3.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeRed1.png b/examples/tappyplane/assets/PNG/Planes/planeRed1.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeRed1.png rename to examples/tappyplane/assets/PNG/Planes/planeRed1.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeRed2.png b/examples/tappyplane/assets/PNG/Planes/planeRed2.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeRed2.png rename to examples/tappyplane/assets/PNG/Planes/planeRed2.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeRed3.png b/examples/tappyplane/assets/PNG/Planes/planeRed3.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeRed3.png rename to examples/tappyplane/assets/PNG/Planes/planeRed3.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeYellow1.png b/examples/tappyplane/assets/PNG/Planes/planeYellow1.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeYellow1.png rename to examples/tappyplane/assets/PNG/Planes/planeYellow1.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeYellow2.png b/examples/tappyplane/assets/PNG/Planes/planeYellow2.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeYellow2.png rename to examples/tappyplane/assets/PNG/Planes/planeYellow2.png diff --git a/examples/quickwings/assets/tappybird/PNG/Planes/planeYellow3.png b/examples/tappyplane/assets/PNG/Planes/planeYellow3.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/Planes/planeYellow3.png rename to examples/tappyplane/assets/PNG/Planes/planeYellow3.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/UIbg.png b/examples/tappyplane/assets/PNG/UI/UIbg.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/UIbg.png rename to examples/tappyplane/assets/PNG/UI/UIbg.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/buttonLarge.png b/examples/tappyplane/assets/PNG/UI/buttonLarge.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/buttonLarge.png rename to examples/tappyplane/assets/PNG/UI/buttonLarge.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/buttonSmall.png b/examples/tappyplane/assets/PNG/UI/buttonSmall.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/buttonSmall.png rename to examples/tappyplane/assets/PNG/UI/buttonSmall.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/medalBronze.png b/examples/tappyplane/assets/PNG/UI/medalBronze.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/medalBronze.png rename to examples/tappyplane/assets/PNG/UI/medalBronze.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/medalGold.png b/examples/tappyplane/assets/PNG/UI/medalGold.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/medalGold.png rename to examples/tappyplane/assets/PNG/UI/medalGold.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/medalSilver.png b/examples/tappyplane/assets/PNG/UI/medalSilver.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/medalSilver.png rename to examples/tappyplane/assets/PNG/UI/medalSilver.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/tap.png b/examples/tappyplane/assets/PNG/UI/tap.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/tap.png rename to examples/tappyplane/assets/PNG/UI/tap.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/tapLeft.png b/examples/tappyplane/assets/PNG/UI/tapLeft.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/tapLeft.png rename to examples/tappyplane/assets/PNG/UI/tapLeft.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/tapRight.png b/examples/tappyplane/assets/PNG/UI/tapRight.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/tapRight.png rename to examples/tappyplane/assets/PNG/UI/tapRight.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/tapTick.png b/examples/tappyplane/assets/PNG/UI/tapTick.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/tapTick.png rename to examples/tappyplane/assets/PNG/UI/tapTick.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/textGameOver.png b/examples/tappyplane/assets/PNG/UI/textGameOver.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/textGameOver.png rename to examples/tappyplane/assets/PNG/UI/textGameOver.png diff --git a/examples/quickwings/assets/tappybird/PNG/UI/textGetReady.png b/examples/tappyplane/assets/PNG/UI/textGetReady.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/UI/textGetReady.png rename to examples/tappyplane/assets/PNG/UI/textGetReady.png diff --git a/examples/quickwings/assets/tappybird/PNG/background.png b/examples/tappyplane/assets/PNG/background.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/background.png rename to examples/tappyplane/assets/PNG/background.png diff --git a/examples/quickwings/assets/tappybird/PNG/groundDirt.png b/examples/tappyplane/assets/PNG/groundDirt.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/groundDirt.png rename to examples/tappyplane/assets/PNG/groundDirt.png diff --git a/examples/quickwings/assets/tappybird/PNG/groundGrass.png b/examples/tappyplane/assets/PNG/groundGrass.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/groundGrass.png rename to examples/tappyplane/assets/PNG/groundGrass.png diff --git a/examples/quickwings/assets/tappybird/PNG/groundIce.png b/examples/tappyplane/assets/PNG/groundIce.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/groundIce.png rename to examples/tappyplane/assets/PNG/groundIce.png diff --git a/examples/quickwings/assets/tappybird/PNG/groundRock.png b/examples/tappyplane/assets/PNG/groundRock.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/groundRock.png rename to examples/tappyplane/assets/PNG/groundRock.png diff --git a/examples/quickwings/assets/tappybird/PNG/groundSnow.png b/examples/tappyplane/assets/PNG/groundSnow.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/groundSnow.png rename to examples/tappyplane/assets/PNG/groundSnow.png diff --git a/examples/quickwings/assets/tappybird/PNG/puffLarge.png b/examples/tappyplane/assets/PNG/puffLarge.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/puffLarge.png rename to examples/tappyplane/assets/PNG/puffLarge.png diff --git a/examples/quickwings/assets/tappybird/PNG/puffSmall.png b/examples/tappyplane/assets/PNG/puffSmall.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/puffSmall.png rename to examples/tappyplane/assets/PNG/puffSmall.png diff --git a/examples/quickwings/assets/tappybird/PNG/rock.png b/examples/tappyplane/assets/PNG/rock.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/rock.png rename to examples/tappyplane/assets/PNG/rock.png diff --git a/examples/quickwings/assets/tappybird/PNG/rockDown.png b/examples/tappyplane/assets/PNG/rockDown.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/rockDown.png rename to examples/tappyplane/assets/PNG/rockDown.png diff --git a/examples/quickwings/assets/tappybird/PNG/rockGrass.png b/examples/tappyplane/assets/PNG/rockGrass.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/rockGrass.png rename to examples/tappyplane/assets/PNG/rockGrass.png diff --git a/examples/quickwings/assets/tappybird/PNG/rockGrassDown.png b/examples/tappyplane/assets/PNG/rockGrassDown.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/rockGrassDown.png rename to examples/tappyplane/assets/PNG/rockGrassDown.png diff --git a/examples/quickwings/assets/tappybird/PNG/rockIce.png b/examples/tappyplane/assets/PNG/rockIce.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/rockIce.png rename to examples/tappyplane/assets/PNG/rockIce.png diff --git a/examples/quickwings/assets/tappybird/PNG/rockIceDown.png b/examples/tappyplane/assets/PNG/rockIceDown.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/rockIceDown.png rename to examples/tappyplane/assets/PNG/rockIceDown.png diff --git a/examples/quickwings/assets/tappybird/PNG/rockSnow.png b/examples/tappyplane/assets/PNG/rockSnow.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/rockSnow.png rename to examples/tappyplane/assets/PNG/rockSnow.png diff --git a/examples/quickwings/assets/tappybird/PNG/rockSnowDown.png b/examples/tappyplane/assets/PNG/rockSnowDown.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/rockSnowDown.png rename to examples/tappyplane/assets/PNG/rockSnowDown.png diff --git a/examples/quickwings/assets/tappybird/PNG/starBronze.png b/examples/tappyplane/assets/PNG/starBronze.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/starBronze.png rename to examples/tappyplane/assets/PNG/starBronze.png diff --git a/examples/quickwings/assets/tappybird/PNG/starGold.png b/examples/tappyplane/assets/PNG/starGold.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/starGold.png rename to examples/tappyplane/assets/PNG/starGold.png diff --git a/examples/quickwings/assets/tappybird/PNG/starSilver.png b/examples/tappyplane/assets/PNG/starSilver.png similarity index 100% rename from examples/quickwings/assets/tappybird/PNG/starSilver.png rename to examples/tappyplane/assets/PNG/starSilver.png diff --git a/examples/quickwings/assets/tappybird/Spritesheet/planes.png b/examples/tappyplane/assets/Spritesheet/planes.png similarity index 100% rename from examples/quickwings/assets/tappybird/Spritesheet/planes.png rename to examples/tappyplane/assets/Spritesheet/planes.png diff --git a/examples/quickwings/assets/tappybird/Spritesheet/planes.xml b/examples/tappyplane/assets/Spritesheet/planes.xml similarity index 100% rename from examples/quickwings/assets/tappybird/Spritesheet/planes.xml rename to examples/tappyplane/assets/Spritesheet/planes.xml diff --git a/examples/quickwings/assets/tappybird/Spritesheet/sheet.png b/examples/tappyplane/assets/Spritesheet/sheet.png similarity index 100% rename from examples/quickwings/assets/tappybird/Spritesheet/sheet.png rename to examples/tappyplane/assets/Spritesheet/sheet.png diff --git a/examples/quickwings/assets/tappybird/Spritesheet/sheet.xml b/examples/tappyplane/assets/Spritesheet/sheet.xml similarity index 100% rename from examples/quickwings/assets/tappybird/Spritesheet/sheet.xml rename to examples/tappyplane/assets/Spritesheet/sheet.xml diff --git a/examples/quickwings/assets/tappybird/Vector/vector.svg b/examples/tappyplane/assets/Vector/vector.svg similarity index 100% rename from examples/quickwings/assets/tappybird/Vector/vector.svg rename to examples/tappyplane/assets/Vector/vector.svg diff --git a/examples/quickwings/assets/tappybird/Vector/vector.swf b/examples/tappyplane/assets/Vector/vector.swf similarity index 100% rename from examples/quickwings/assets/tappybird/Vector/vector.swf rename to examples/tappyplane/assets/Vector/vector.swf diff --git a/examples/quickwings/assets/tappybird/license.txt b/examples/tappyplane/assets/license.txt similarity index 100% rename from examples/quickwings/assets/tappybird/license.txt rename to examples/tappyplane/assets/license.txt diff --git a/examples/quickwings/assets/tappybird/preview.png b/examples/tappyplane/assets/preview.png similarity index 100% rename from examples/quickwings/assets/tappybird/preview.png rename to examples/tappyplane/assets/preview.png diff --git a/examples/quickwings/assets/tappybird/sample.png b/examples/tappyplane/assets/sample.png similarity index 99% rename from examples/quickwings/assets/tappybird/sample.png rename to examples/tappyplane/assets/sample.png index efccaf41be84dda2d60704f099885b4532ec89b6..55328036a4be96591ded081c18b6f214af3869bf 100644 GIT binary patch delta 13 UcmezWkEP*1OT!k%dV5AL05Povg8%>k delta 11 ScmZqp&+`8tOT!k%dV2sRHwAbA diff --git a/examples/tappyplane/tappyplane.cpp b/examples/tappyplane/tappyplane.cpp new file mode 100644 index 0000000..cda1265 --- /dev/null +++ b/examples/tappyplane/tappyplane.cpp @@ -0,0 +1,456 @@ +/** + * paradiso - Paradigmen der Softwareentwicklung + * + * (c) Copyright 2023-2025 Hartmut Seichter and Contributors + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +static const unsigned int FRAME_RATE = 60; +static const unsigned int WINDOW_WIDTH = 800; +static const unsigned int WINDOW_HEIGHT = 480; +static const unsigned int WINDOW_SCALE = 2; + +// x,y+h --- x+w,y+h +// | | +// | | +// | | +// x,y ----- x+w,y +struct AABB { + paradiso::Vector2 position{}; + paradiso::Vector2 size{}; + + bool is_colliding_with(const AABB& other) { + return position.x() < other.position.x() + other.size.x() && + position.x() + size.x() > other.position.x() && + position.y() < other.position.y() + other.size.y() && + position.y() + size.y() > other.position.y(); + } +}; + +struct Background { + static constexpr float SCROLLING_SPEED = 0.003f; + + std::array sprites; + paradiso::Renderer renderer{}; + + paradiso::Bitmap image = + paradiso::BitmapIO::get().load("PNG/background.png"); + + void init() { + sprites = {paradiso::Sprite{ + .bitmap = image, + .pivot = {paradiso::Vector2::make(0.0f, 0.0f)}, + .scale = {paradiso::Vector2::make(1.0f, 1.0f)}}, + paradiso::Sprite{ + .bitmap = image, + .pivot = {paradiso::Vector2::make(2.0f, 0.0f)}, + .scale = {paradiso::Vector2::make(1.0f, 1.0f)}}}; + } + + void update() { + for (auto& sprite : sprites) { + sprite.pivot.x() -= SCROLLING_SPEED; + if (sprite.pivot.x() <= -2.0f) { + sprite.pivot.x() += 4.0f; + } + } + } + + void draw(const paradiso::Shader& shader) { + for (const auto& sprite : sprites) { + shader.set_uniform("pivot", sprite.pivot); + shader.set_uniform("scale", sprite.scale); + shader.set_uniform("rotation", sprite.rotation); + renderer.draw(sprite, shader); + } + } +}; + +struct Ground { + static constexpr float SCROLLING_SPEED = 0.009f; + + std::array sprites; + paradiso::Renderer renderer{}; + + // Maybe put this into 'init()' because we might use the other textures + // like snow, ice, ... and then we can parameterize this. + paradiso::Bitmap image = + paradiso::BitmapIO::get().load("PNG/groundGrass.png"); + + AABB aabb{}; + + void init() { + // The image's height is 71 px. + float scale_y = 71.0f / (float)WINDOW_HEIGHT; + + float pivot_y = -1.0f + scale_y; + + sprites = { + paradiso::Sprite{ + .bitmap = image, + .pivot = {paradiso::Vector2::make(0.0f, pivot_y)}, + .scale = {paradiso::Vector2::make(1.0f, scale_y)}}, + paradiso::Sprite{ + .bitmap = image, + .pivot = {paradiso::Vector2::make(2.0f, pivot_y)}, + .scale = {paradiso::Vector2::make(1.0f, scale_y)}}}; + + // We'll make the height half the height of the texture. + // (If you want 1:1 size, you need to double the scale of the sprite.) + aabb = AABB{ + .position = {paradiso::Vector2::make(-1.0f, -1.0f)}, + .size = {paradiso::Vector2::make(2.0f, scale_y)} + }; + } + + void update() { + for (auto& sprite : sprites) { + sprite.pivot.x() -= SCROLLING_SPEED; + if (sprite.pivot.x() <= -2.0f) { + sprite.pivot.x() += 4.0f; + } + } + } + + void draw(const paradiso::Shader& shader) { + for (const auto& sprite : sprites) { + shader.set_uniform("pivot", sprite.pivot); + shader.set_uniform("scale", sprite.scale); + shader.set_uniform("rotation", sprite.rotation); + renderer.draw(sprite, shader); + } + } +}; + +struct Rocks { + static constexpr float SCROLLING_SPEED = 0.006f; + static constexpr float GAP_SIZE = 1.6f; + + paradiso::Sprite top_sprite; + paradiso::Sprite bottom_sprite; + + paradiso::Renderer top_renderer{}; + paradiso::Renderer bottom_renderer{}; + + // Maybe put this into 'init()' because we might use the other textures + // like snow, ice, ... and then we can parameterize this. + paradiso::Bitmap top_image = + paradiso::BitmapIO::get().load("PNG/rockGrassDown.png"); + paradiso::Bitmap bottom_image = + paradiso::BitmapIO::get().load("PNG/rockGrass.png"); + + AABB top_aabb; + AABB bottom_aabb; + + void init(float x) { + // The image's size is 108x239 px. + float scale_x = 108.0f / (float)WINDOW_WIDTH; + float scale_y = 239.0f / (float)WINDOW_HEIGHT; + auto scale = paradiso::Vector2{ + paradiso::Vector2::make(scale_x, scale_y)}; + + float top_position_y = + 1.0f - scale_y + ((float)(std::rand() % 60) / 100) + 0.04f; + float bottom_position_y = top_position_y - GAP_SIZE; + + top_sprite = paradiso::Sprite{ + .bitmap = top_image, + .pivot = {paradiso::Vector2::make(x, top_position_y)}, + .scale = scale}; + + bottom_sprite = paradiso::Sprite{ + .bitmap = bottom_image, + .pivot = {paradiso::Vector2::make(x, bottom_position_y)}, + .scale = scale}; + + // We'll make the width half the width of the texture. + // (If you want 1:1 size, you need to double the scale of the sprite.) + auto size = paradiso::Vector2{ + paradiso::Vector2::make(scale_x, scale_y * 2)}; + + auto top_position = + paradiso::Vector2{paradiso::Vector2::make( + top_sprite.pivot.x() - size.x() / 2, + top_sprite.pivot.y() - size.y() / 2)}; + + auto bottom_position = + paradiso::Vector2{paradiso::Vector2::make( + bottom_sprite.pivot.x() - size.x() / 2, + bottom_sprite.pivot.y() - size.y() / 2)}; + + top_aabb = AABB{top_position, size}; + bottom_aabb = AABB{bottom_position, size}; + } + + void update() { + top_sprite.pivot.x() -= SCROLLING_SPEED; + bottom_sprite.pivot.x() -= SCROLLING_SPEED; + + // +----------+ + // | | + // | # #-------- the x it is. + // | \ | + // +----\-----+ + // \ + // *------- the x we need. + + // @Efficiency: We could just scroll it with the sprite. + top_aabb.position.x() = top_sprite.pivot.x() - top_aabb.size.x() / 2; + bottom_aabb.position.x() = + bottom_sprite.pivot.x() - bottom_aabb.size.x() / 2; + + if (top_sprite.pivot.x() <= -1.2f) { + // Reset. + init(1.2f); + return; + } + } + + void draw(const paradiso::Shader& shader) { + shader.set_uniform("pivot", top_sprite.pivot); + shader.set_uniform("scale", top_sprite.scale); + shader.set_uniform("rotation", top_sprite.rotation); + top_renderer.draw(top_sprite, shader); + + shader.set_uniform("pivot", bottom_sprite.pivot); + shader.set_uniform("scale", bottom_sprite.scale); + shader.set_uniform("rotation", bottom_sprite.rotation); + bottom_renderer.draw(bottom_sprite, shader); + } +}; + +struct Plane { + static const unsigned int SPRITE_COUNT = 3; + static constexpr float GRAVITY = -0.001f; + static constexpr float JUMP_VELOCITY = 0.03f; + static constexpr float MAX_VELOCITY = 0.03f; + + std::array sprites; + std::array renderers; + + unsigned int anim_interval = 10; + unsigned int anim_counter = 0; + + // The direction where 'current_sprite' should go because the animation + // shouldn't loop. + int anim_direction = 1; + + unsigned int current_sprite = 0; + + float position_y = 0.5f; + float rotation = 0.0f; + + float velocity_y = 0.0f; + + AABB aabb; + + void init() { + // The image's size is 88x73 px. + float scale_x = 88.0f / (float)WINDOW_WIDTH; + float scale_y = 73.0f / (float)WINDOW_HEIGHT; + + auto pivot = paradiso::Vector2{ + paradiso::Vector2::make(0.0f, position_y)}; + auto scale = paradiso::Vector2{ + paradiso::Vector2::make(scale_x, scale_y)}; + + sprites = { + paradiso::Sprite{.bitmap = paradiso::BitmapIO::get().load( + "PNG/Planes/planeRed1.png"), + .pivot = pivot, + .scale = scale}, + paradiso::Sprite{.bitmap = paradiso::BitmapIO::get().load( + "PNG/Planes/planeRed2.png"), + .pivot = pivot, + .scale = scale}, + paradiso::Sprite{.bitmap = paradiso::BitmapIO::get().load( + "PNG/Planes/planeRed3.png"), + .pivot = pivot, + .scale = scale}, + }; + + // We'll make the size half the size of the texture. + // (If you want 1:1 size, you need to double the scale of the sprite.) + auto size = paradiso::Vector2{ + paradiso::Vector2::make(scale_x, scale_y)}; + + // Center it. + auto position = paradiso::Vector2{paradiso::Vector2::make( + pivot.x() - size.x() / 2, pivot.y() - size.y() / 2)}; + + aabb = AABB{position, size}; + } + + void update(const paradiso::Window::KeyboardInputStack& input) { + if (anim_counter < anim_interval) { + anim_counter++; + } else { + anim_counter = 0; + + current_sprite += anim_direction; + if (current_sprite == SPRITE_COUNT - 1) { + anim_direction = -1; + } else if (current_sprite == 0) { + anim_direction = 1; + } + } + + if (input.size() && input.top().key == ' ' && input.top().action == 1) { + velocity_y += JUMP_VELOCITY; + } else { + velocity_y += GRAVITY; + } + + velocity_y = std::clamp(velocity_y, -MAX_VELOCITY, MAX_VELOCITY); + position_y += velocity_y; + + // +---------+ + // | | + // | #------- the y it is. + // | | + // +----#----+ + // \ + // *----- the y we need. + + // @Efficiency: We could just add the velocity. + aabb.position.y() = position_y - aabb.size.y() / 2; + + rotation = velocity_y * 500.0f; + } + + void draw(const paradiso::Shader& shader) { + auto sprite = sprites[current_sprite]; + sprite.rotation = rotation * (std::numbers::pi / 180.0f); + sprite.pivot.y() = position_y; + + shader.set_uniform("pivot", sprite.pivot); + shader.set_uniform("scale", sprite.scale); + shader.set_uniform("rotation", sprite.rotation); + renderers[current_sprite].draw(sprite, shader); + } +}; + +auto main() -> int { + std::srand(std::time(nullptr)); + + auto canvas_size = paradiso::Size{.width = WINDOW_WIDTH * WINDOW_SCALE, + .height = WINDOW_HEIGHT * WINDOW_SCALE}; + + // Unser Fenster, auf das wir rendern. + auto window = paradiso::Window(); + window + .set_size(canvas_size) // ... Größe + .set_position(paradiso::Point{.x = 200, .y = 200}) // ... Position + .set_title("ParadiSO.TappyPlane") // ... Titel + .set_visible(true); // ... und jetzt anzeigen! + + // Der Fenster Context. + auto context = paradiso::Context{}; + + // Ein Shader (Schattierungsprogramm). + auto shader = paradiso::Shader{}; + + // Wir nutzen einen vorgefertigten Shader, der speziell für Sprites ist. + shader.load_preset(paradiso::Shader::Preset::Sprite); + + // Ein Viewport stellt die Sicht der Kamera dar, d.h. bei quadratischen + // Pixeln sollte hier auch eine dementsprechende Größe eingestellt + // werden. + context.set_viewport(paradiso::Rectangle{ + .position = paradiso::Point{.x = 0, .y = 0}, .size = canvas_size}); + + // Conflower blue + context.set_clearcolor(paradiso::RGBA::from_rgb(0x64, 0x95, 0xED)); + + // Der Asset Loader bekommt den Pfad. + paradiso::BitmapIO::get().set_path("assets"); + + // Wir initialisieren unsere Sachen. + auto background = Background{}; + background.init(); + + auto ground = Ground{}; + ground.init(); + + auto rocks1 = Rocks{}; + rocks1.init(1.2f); + + auto rocks2 = Rocks{}; + rocks2.init(2.4f); + + auto plane = Plane{}; + plane.init(); + + auto top_aabb = + AABB{.position = {paradiso::Vector2::make(-1.0f, 1.0f)}, + .size = {paradiso::Vector2::make(2.0f, 0.5f)}}; + + while (window.update([&](paradiso::Window& window) -> bool { + background.update(); + ground.update(); + + rocks1.update(); + rocks2.update(); + + plane.update(window.keyboard_input()); + + if (plane.aabb.is_colliding_with(rocks1.top_aabb) || + plane.aabb.is_colliding_with(rocks1.bottom_aabb) || + plane.aabb.is_colliding_with(rocks2.top_aabb) || + plane.aabb.is_colliding_with(rocks2.bottom_aabb) || + plane.aabb.is_colliding_with(top_aabb) || + plane.aabb.is_colliding_with(ground.aabb)) { + + std::cout << "COLLIDING" << std::endl; + } + + auto t1 = std::chrono::high_resolution_clock::now(); + + context.set_viewport(paradiso::Rectangle{ + .position = paradiso::Point{.x = 0, .y = 0}, .size = canvas_size}); + context.clear(); + + background.draw(shader); + + plane.draw(shader); + + rocks1.draw(shader); + rocks2.draw(shader); + + ground.draw(shader); + + // Einen kurzen Moment warten, um auf 60 FPS zu kommen. + auto t2 = std::chrono::high_resolution_clock::now(); + auto duration = + std::chrono::duration_cast(t2 - t1); + auto wait = std::chrono::microseconds(1000000 / FRAME_RATE) - duration; + std::this_thread::sleep_for(wait); + + if (window.keyboard_input().size() && + window.keyboard_input().top().key == 'Q') { + // Update-Loop beenden. + return false; + } + + return true; + })) { + }; + + return 0; +}