From 28e08f08c2a661ac50b58bd9af84678c8cc1894b Mon Sep 17 00:00:00 2001 From: Mim Hufford Date: Wed, 2 Jun 2021 12:18:57 +0100 Subject: [PATCH] FlappyBug: Add new graphics and tweak colors This adds some actual graphics to the game, and tweaks the obstacle and sky colors. Eventually there will be graphics for those elements too. --- Base/res/icons/16x16/app-flappybug.png | Bin 182 -> 195 bytes Base/res/icons/32x32/app-flappybug.png | Bin 241 -> 279 bytes Base/res/icons/flappybug/falling.png | Bin 0 -> 247 bytes Base/res/icons/flappybug/flapping.png | Bin 0 -> 279 bytes Userland/Games/FlappyBug/Game.cpp | 15 ++++++++------- Userland/Games/FlappyBug/Game.h | 11 ++++++++++- 6 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 Base/res/icons/flappybug/falling.png create mode 100644 Base/res/icons/flappybug/flapping.png diff --git a/Base/res/icons/16x16/app-flappybug.png b/Base/res/icons/16x16/app-flappybug.png index ebb81a51f0cd40c6f834c0058a739b6a7079acef..cb79000fe64a5f8af8a1fc356ede26d67050acb2 100644 GIT binary patch delta 147 zcmdnSc$jg5MLmN*0|SFUV{+Hu>kJGGJOMr-t_)!CpMl~3|Nj>!@A6<^U|=Z;@(Tv> zH|sidFfcGUc)B=-RLn_EU|`l{R}eI1^vF2JurbWYz`#v6IU#}fEMKAkZ?xp$15#Ue uv3R7g8W=2NRF&8g*1$1=FN{rvf#J72_lZmAyqEKU?DBN=b6Mw<&;$S=D=lIG delta 133 zcmX@ixQ%gwMIE;=0|U1(Bg3pY5)2FsoB=)|t_)!CpMk;l_g!5E1_tJmAirRS|NmVA zt|>AwFqnI~IEGZrNlsvB4qz7$WKeN&ZfFS;n=oVRn#RV=t6B;hi>5NS95vu}X-JK9 iPOv&q<*M+^fPq10F|WlbznSwvrhB^jxvXN`m}?LHy0S4jl{(3{yN^978JR zw4OKQYc}9v4KO;uyW-02k_QZuuR>g$bYedoNj-64XUHk{72!ED=}sPBC#fIZSikDk zniX?Q*DN}?YDdu?%?+<&g_oBzCb@C9Dn3xXYiiiEAV`&8CpOCA$+m;b#EL!|o@45t zYb0?$ahhDswu`5OJ@;E~kmw|zSxg^LhnBo6_mw;=E3=9lKo-U3d6?2jk z92l-KXgHgQoZ{l;Z8UU}T@Vz&maP#YsN8cK*T% elRDHO%D}+4!o+>o7xOrf%RF8ET-G@yGywntZ#!84 diff --git a/Base/res/icons/flappybug/falling.png b/Base/res/icons/flappybug/falling.png new file mode 100644 index 0000000000000000000000000000000000000000..df97fed13fb982b417a9b0e9e9623b85ccf7fc76 GIT binary patch literal 247 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;ICT0c(20oEV=?n}EjKx9jPK-BC>eMqZFmM)l zL>4nJa0`PlBg3pY5)2FsJOMr-t_)!CpMl~3|Nj>!@A6<^U|=Z;@(Tv>H|sidFfcHb zc)B=-RLoi1zmd1Wfx~sDllg{1DQ@-+6O1oKct16I&Nl0g`7u$}QkKjgKWpR~Uu@?( zv%X`(y=umZcV?^zU8v{Asi3rpdk$Nqg@YCV%BQ+a!C(>iBip o4CBIt&izopr05WD$LjV8( literal 0 HcmV?d00001 diff --git a/Base/res/icons/flappybug/flapping.png b/Base/res/icons/flappybug/flapping.png new file mode 100644 index 0000000000000000000000000000000000000000..13db9e46e94d51a7e846816d7b39051086d69c40 GIT binary patch literal 279 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;ICT0c(20oEV=?n}EjKx9jPK-BC>eMqZFmM)l zL>4nJa0`PlBg3pY5)2FsJOMr-t_)!CpMl~3|Nj>!@A6<^U|=Z;@(Tv>H|sidFfcGo z@pN$vshHDx-jJ`^fQL1}=m77EE4ND?Fi5@%adFa#{ct4p#D$$9r`%VB=g6cxd3>Fu zesp8~s#j}P%rRZF=-{dyMSCrect()); if (m_active) { - painter.draw_text({ 10, 10, 100, 100 }, String::formatted("{:.0}", m_difficulty), Gfx::TextAlignment::TopLeft, Color::Green); + painter.draw_text({ 10, 10, 100, 100 }, String::formatted("{:.0}", m_difficulty), Gfx::TextAlignment::TopLeft, Color::White); } else if (m_highscore.has_value()) { auto message = String::formatted("Your score: {:.0}\nHighscore: {:.0}\n\n{}", m_last_score, m_highscore.value(), m_restart_cooldown < 0 ? "Press any key to play again" : " "); - painter.draw_text(rect(), message, Gfx::TextAlignment::Center, Color::Green); + painter.draw_text(rect(), message, Gfx::TextAlignment::Center, Color::White); } else { - painter.draw_text(rect(), "Press any key to start", Gfx::TextAlignment::Center, Color::Green); + painter.draw_text(rect(), "Press any key to start", Gfx::TextAlignment::Center, Color::White); } } diff --git a/Userland/Games/FlappyBug/Game.h b/Userland/Games/FlappyBug/Game.h index 1b7dbe6c08..09876bdbfb 100644 --- a/Userland/Games/FlappyBug/Game.h +++ b/Userland/Games/FlappyBug/Game.h @@ -38,8 +38,10 @@ private: struct Bug { const float x { 50 }; - const float radius { 10 }; + const float radius { 16 }; const float starting_y { 200 }; + const RefPtr falling_bitmap { Gfx::Bitmap::load_from_file("/res/icons/flappybug/falling.png") }; + const RefPtr flapping_bitmap { Gfx::Bitmap::load_from_file("/res/icons/flappybug/flapping.png") }; float y {}; float velocity {}; @@ -48,6 +50,11 @@ private: y = starting_y; } + RefPtr current_bitmap() const + { + return velocity < 0 ? falling_bitmap : flapping_bitmap; + } + Gfx::FloatRect rect() const { return { x - radius, y - radius, radius * 2, radius * 2 }; @@ -73,6 +80,7 @@ private: struct Obstacle { const float width { 20 }; + Color color { Color::DarkGray }; float x; float gap_top_y { 200 }; float gap_height { 175 }; @@ -101,6 +109,7 @@ private: float m_last_score; float m_difficulty; float m_restart_cooldown; + Color m_sky_color { 100, 100, 200 }; }; }