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>p%uifKP}kkOqSPK=l9r#mT!ofE<>RAirP`f3vPb z2axaJ>EaktF()~JfmxGXLC}=ZBjX&y#xNrT12^5|gaqERe2D_Q(UOM`NNwH4;*r8? qV6co)Rboq61IGluFg6tihTrnsCoY}yUd{tFjKR~@&t;ucLK6TWD=lIG delta 133 zcmX@ixQ%gwMIE;=0|U1(Bg3pY5)2FsoB=)|u0R?H{xdMx{=TaVWHFZn`2{ol|L+oT zO%cd7_jGX#shE?Tz|b7PE+ELD;^N%U5+*ib#@02BjhR=q6gC!3Wo|iY!0pnI8tI&1 hb)d>s;h6yggU(`Ji&K6x=L3yk@O1TaS?83{1ORjhC&2&! diff --git a/Base/res/icons/32x32/app-flappybug.png b/Base/res/icons/32x32/app-flappybug.png index dae5073be6185feab9083412ac07fd49fc767695..13db9e46e94d51a7e846816d7b39051086d69c40 100644 GIT binary patch delta 217 zcmey!IGt&NTRl&JPlzi682o2o`2YX^#mT!ofLxZ6AirP`f3vPb2arF-)5S5QVovLM zL%wDM9@YS(1H3D)+%9>*Ao(i9#Yrdj!;#bz7j}l6a$gaiBa`mr@pY2=(T(-1UaeU% z$8^o2gR6EF?a|!uDpq)TIb)I=cdOz9)w`yKO$&ll`E_EW9G+}DxJ<0*qv1KG{<%gH z_YgTe~DWM4fL+M*G delta 179 zcmbQv^pSCbTRmrhPlzi682o2ou>E~k7szHV3GxeO`2XJ};F=yG&`QPxtH%pX5%P}{ 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!ia0vp^3LwnH3?%tPCZz)@#^NA%C&rs6b?Si}&H|6fVg?3o zVGw3ym^DWND997w6XFV_f#5$7{r`V)@-7b`hovOQFBrt%tn1JLJ zui1cyHNfZq?}{t8OCB&tz6x=1(uw_WB=y9Fogt^(SA^%tq&snB>OYs`xv8&E}qh62?*bC!arect()); 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 1b7dbe6c08c..09876bdbfb5 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 }; }; }