From 157531245491cfa69e364686ed83f0b116c82584 Mon Sep 17 00:00:00 2001 From: Braydon Kains Date: Fri, 4 Jan 2019 03:19:20 -0500 Subject: [PATCH] basically the whole game tbh without sound --- TrustFall/TrustFall/BigMrManager.bmp | Bin 19322 -> 19322 bytes TrustFall/TrustFall/TrustFall.vcxproj | 16 ++ TrustFall/TrustFall/TrustFall.vcxproj.filters | 18 +++ TrustFall/TrustFall/cursor.h | 2 + TrustFall/TrustFall/game.cpp | 19 ++- TrustFall/TrustFall/game_screen.cpp | 143 +++++++++++++++--- TrustFall/TrustFall/game_screen.h | 7 +- TrustFall/TrustFall/line.cpp | 44 +++--- TrustFall/TrustFall/line.h | 2 +- TrustFall/TrustFall/mrmanagerhappy.bmp | Bin 0 -> 19322 bytes TrustFall/TrustFall/mrmanagersad.bmp | Bin 0 -> 19322 bytes TrustFall/TrustFall/result_screen.cpp | 88 +++++++++++ TrustFall/TrustFall/result_screen.h | 18 +++ TrustFall/TrustFall/small_key_ctrl.bmp | Bin 0 -> 2882 bytes TrustFall/TrustFall/small_key_esc.bmp | Bin 0 -> 2882 bytes TrustFall/TrustFall/small_key_h.bmp | Bin 0 -> 2882 bytes TrustFall/TrustFall/small_key_m.bmp | Bin 0 -> 2882 bytes TrustFall/TrustFall/start_screen.cpp | 20 ++- 18 files changed, 323 insertions(+), 54 deletions(-) create mode 100644 TrustFall/TrustFall/mrmanagerhappy.bmp create mode 100644 TrustFall/TrustFall/mrmanagersad.bmp create mode 100644 TrustFall/TrustFall/result_screen.cpp create mode 100644 TrustFall/TrustFall/result_screen.h create mode 100644 TrustFall/TrustFall/small_key_ctrl.bmp create mode 100644 TrustFall/TrustFall/small_key_esc.bmp create mode 100644 TrustFall/TrustFall/small_key_h.bmp create mode 100644 TrustFall/TrustFall/small_key_m.bmp diff --git a/TrustFall/TrustFall/BigMrManager.bmp b/TrustFall/TrustFall/BigMrManager.bmp index f1bbfa8a0da5cdca9593226c0403b36f9e19501d..6a972421034121243e8db2e86db4db6eb833c645 100644 GIT binary patch literal 19322 zcmeH_&5jf?41@=sf;)E}VlNyJ65=_yaod+)qBU6GwA+dEGd)SuE6r?mrCh0U&&&7M zZ@2fq*Yy1>eSZA?e7Jpj=Wpr!^B4IDal5^I{rUSJj{g4`6*{`N$^M*}!|2KCz6~qp z7)f8}Fhp}>p#ewKpTse~qx)}Jw=a`he77b%Pzm}DQe&}5g})nnz=PgmV_0VQe#(jh ziiy*pJnlLSBzbAVp0moVK#z9E_0$duqXGe*Y!uJy@}8>P$dpgOJKFG@$Be^9+5f0_ zMXXd@1*)7Q;vS78k2_Q~P2yVTxc(TW-48dw3|7h0Rj_Sw^_6#LH?zt+Wlr1TdcW8E zva>#U~J4ecN6l_x5PqmQbdct=Wer$KWAR+f1}z+xTWm-3X{ro@5;BcmnY$ zRqD7h{XjhhSVI-qqavfT2^7T}fzEFD{>P$oQQ&3J!2~?bF0X^Tr~PCxPg?+;D*Cg6 zPLVtwH^k79hQ7xav^PqA%X>^)U(YShU-!m$)uX)j+_Sy-?Ekjs_-4i`pS9<)E#hvY z`qC$ly=?g@o_Y=u{t-U(wAf2!l^)|cM0k2e^qxk1cuHqtYKW;Jwi+_E*mG|4;S`;T zsUfC@*lNhsV$ZqFhf{PWriPdrVyhuji#_KyA5PJkm>Obgh^>Z9E%uz-d^kmCVrqz~ zA+{Pawb*lR^T|)iU7jX?DpL`S=TC=GK9RdTO(a7^?8uR2<*u>$tK78g?v#yZ85y*^Ws*|J^u2rCqsij!HnU}_ z`aZF8v8-m}+S%8`-Uiesa>!f)ebpb3f@Idu)3j24Yq zaEj~Spso}|;l>n-Dqms?%4TRu_Tp22Ynt?wVs@ej((o^1gI+l#HwIC>cd1fezmh&g z59Yo?ht+%_+92l=qj;NBSdu=$FGWLtf8*g!4f##vr&ADqE#dhM@05lRF0GZe8kBiQ zt#Z$h<_6+pswT7<(2>k8>Q_Z>TzsMqYK=Oha^W`9toh9t%s&vrAm$kh&!7OaZUP>B zhCT2(ROS|WI!o3__&;G??3IfxBfCdc(5eV+`HD_0AdIX A!Ttrue true + + true + true + true + true + true + true + true + true + Level3 @@ -138,19 +148,25 @@ + + + + + + diff --git a/TrustFall/TrustFall/TrustFall.vcxproj.filters b/TrustFall/TrustFall/TrustFall.vcxproj.filters index 631ad32..4c20cbd 100644 --- a/TrustFall/TrustFall/TrustFall.vcxproj.filters +++ b/TrustFall/TrustFall/TrustFall.vcxproj.filters @@ -54,6 +54,15 @@ Source Files\TrustFallImplement + + Source Files + + + Source Files + + + Source Files\ScreensImplement + @@ -77,5 +86,14 @@ Header Files\TrustFall + + Header Files + + + Header Files + + + Header Files\Screens + \ No newline at end of file diff --git a/TrustFall/TrustFall/cursor.h b/TrustFall/TrustFall/cursor.h index 8409560..a668e6d 100644 --- a/TrustFall/TrustFall/cursor.h +++ b/TrustFall/TrustFall/cursor.h @@ -1,4 +1,6 @@ #pragma once +#include +#include #include template diff --git a/TrustFall/TrustFall/game.cpp b/TrustFall/TrustFall/game.cpp index 719563d..91b68d7 100644 --- a/TrustFall/TrustFall/game.cpp +++ b/TrustFall/TrustFall/game.cpp @@ -1,6 +1,7 @@ #include "game.h" #include "start_screen.h" #include "game_screen.h" +#include "result_screen.h" using std::string; using std::map; @@ -15,13 +16,19 @@ void Game::init() { sprites.insert(pair("Title", al_load_bitmap("logo.bmp"))); sprites.insert(pair("Mr. Man", al_load_bitmap("MrMan.bmp"))); sprites.insert(pair("Mr. Manager", al_load_bitmap("BigMrManager.bmp"))); + sprites.insert(pair("Mr. ManagerSad", al_load_bitmap("mrmanagersad.bmp"))); + sprites.insert(pair("Mr. ManagerHappy", al_load_bitmap("mrmanagerhappy.bmp"))); sprites.insert(pair("KeyUp", al_load_bitmap("small_key_up.bmp"))); sprites.insert(pair("Spacebar", al_load_bitmap("spacebar.bmp"))); sprites.insert(pair("Employee", al_load_bitmap("employee.bmp"))); sprites.insert(pair("EmployeeHappy", al_load_bitmap("employee_happy.bmp"))); sprites.insert(pair("EmployeeSad", al_load_bitmap("employee_sad.bmp"))); sprites.insert(pair("Conveyor", al_load_bitmap("conveyor.bmp"))); - + sprites.insert(pair("KeyCtrl", al_load_bitmap("small_key_ctrl.bmp"))); + sprites.insert(pair("KeyH", al_load_bitmap("small_key_h.bmp"))); + sprites.insert(pair("KeyM", al_load_bitmap("small_key_m.bmp"))); + sprites.insert(pair("KeyEsc", al_load_bitmap("small_key_esc.bmp"))); + font = al_create_builtin_font(); } @@ -31,8 +38,9 @@ void Game::reset() { } void Game::run() { + GameScreen game_screen(sprites); StartScreen start_screen(sprites); - GameScreen game_screen(sprites, 3); + ResultScreen result_screen(sprites, 0, 0); while (state != Exit) { al_clear_to_color(al_map_rgb(0, 0, 0)); switch (state) { @@ -41,9 +49,16 @@ void Game::run() { state = start_screen.next_state; break; case Gameplay: + game_screen.reset(3, 5, 3); game_screen.run(font); state = game_screen.next_state; break; + case End: + result_screen.score = game_screen.score; + result_screen.difficulty = game_screen.difficulty; + result_screen.run(font); + state = result_screen.next_state; + break; } } } \ No newline at end of file diff --git a/TrustFall/TrustFall/game_screen.cpp b/TrustFall/TrustFall/game_screen.cpp index 8ecbf51..c4d2fcc 100644 --- a/TrustFall/TrustFall/game_screen.cpp +++ b/TrustFall/TrustFall/game_screen.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "game_screen.h" @@ -9,48 +11,86 @@ using std::vector; using std::string; +using std::ostringstream; +using std::map; +using std::pair; -GameScreen::GameScreen(std::map _sprites, int _lines) { +GameScreen::GameScreen(std::map _sprites) { sprites = _sprites; +} +void GameScreen::reset(int _lines, int _max_catchers, int _difficulty) { + if (!lines.empty()) { + lines.erase(lines.begin(), lines.begin() + _lines); + } for (int i = 0; i < _lines; i++) { - Line new_line(SCREEN_W/2, SCREEN_H/_lines * i, sprites); + Line new_line(SCREEN_W / 2, SCREEN_H / _lines * i, sprites); lines.push_back(new_line); } selected = 0; + max_catchers = _max_catchers; + catchers = 0; + score = 0; + difficulty = _difficulty; } -void GameScreen::run(ALLEGRO_FONT * font) { +void GameScreen::run(ALLEGRO_FONT* font) { bool music = true; + bool help = false; + map difficulty_map; + difficulty_map.insert(pair(1, 15)); + difficulty_map.insert(pair(2, 12)); + difficulty_map.insert(pair(3, 10)); + difficulty_map.insert(pair(4, 8)); + difficulty_map.insert(pair(5, 5)); + ALLEGRO_EVENT_QUEUE* event_queue = NULL; event_queue = al_create_event_queue(); al_register_event_source(event_queue, al_get_keyboard_event_source()); ALLEGRO_TIMER* timer = NULL; - timer = al_create_timer(1.5); + timer = al_create_timer(0.1); al_register_event_source(event_queue, al_get_timer_event_source(timer)); - + redraw(font); al_flip_display(); + int ticks = 0; bool exit_screen = false; + bool ctrl = false; al_start_timer(timer); while (!exit_screen) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &ev); if (ev.type == ALLEGRO_EVENT_TIMER) { - int add_to = rand() % (lines.size()+1); - for (int i = 0; i < lines.size(); i++) { - if (i == add_to) { - lines.at(i).add_employee(); + if (ticks == difficulty_map[difficulty]) { + int add_to = rand() % (lines.size() + 1); + for (unsigned int i = 0; i < lines.size(); i++) { + if (i == add_to) { + lines.at(i).add_employee(); + } + lines.at(i).move(); + if (lines.at(i).fall) { + exit_screen = true; + } + else if (lines.at(i).caught) { + catchers--; + score++; + if ((score == 10 || score == 20 || score == 30 || score == 40 || score == 50) && difficulty < 5) { + difficulty++; + } + } } - lines.at(i).move(); + al_clear_to_color(al_map_rgb(0, 0, 0)); + redraw(font); + al_flip_display(); + ticks = 0; + } + else { + ticks++; } - al_clear_to_color(al_map_rgb(0, 0, 0)); - redraw(font); - al_flip_display(); } if (ev.type == ALLEGRO_EVENT_KEY_DOWN) { switch (ev.keyboard.keycode) { @@ -61,37 +101,98 @@ void GameScreen::run(ALLEGRO_FONT * font) { if (selected > 0) selected--; break; case ALLEGRO_KEY_SPACE: - lines.at(selected).add_catcher(); + if (catchers < max_catchers) { + lines.at(selected).add_catcher(); + catchers++; + } break; case ALLEGRO_KEY_M: if (ev.keyboard.modifiers == ALLEGRO_KEYMOD_CTRL) { - music = false; + music = !music; } break; case ALLEGRO_KEY_H: - if (ev.keyboard.modifiers == ALLEGRO_KEYMOD_CTRL) { - music = music; //INCOMPLETE + if (ctrl) { + help = true; + + al_clear_to_color(al_map_rgb(0, 0, 0)); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 20, ALLEGRO_ALIGN_CENTER, "Place catchers at the ends of the conveyors"); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 30, ALLEGRO_ALIGN_CENTER, "You can place 3 catchers per conveyor"); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 40, ALLEGRO_ALIGN_CENTER, "Make sure to keep track of how many catchers you have left"); + + al_draw_bitmap(sprites["KeyUp"], SCREEN_W / 8, SCREEN_H / 2 + 60, NULL); + al_draw_bitmap(sprites["KeyUp"], SCREEN_W / 8 + 34, SCREEN_H / 2 + 60, ALLEGRO_FLIP_VERTICAL); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 8 + 68, SCREEN_H / 1.5 - 10, ALLEGRO_ALIGN_LEFT, "Up and down - Move cursor"); + + al_draw_bitmap(sprites["Spacebar"], SCREEN_W / 8 + 20, SCREEN_H / 2 + 100, NULL); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 8 + 68, SCREEN_H / 1.3 - 20, ALLEGRO_ALIGN_LEFT, "Spacebar - Place employee"); + + al_draw_bitmap(sprites["KeyEsc"], SCREEN_W / 2 + 58, SCREEN_H / 2 + 60, NULL); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2 + 113, SCREEN_H / 1.5 - 10, ALLEGRO_ALIGN_LEFT, "Close menu"); + + al_draw_bitmap(sprites["KeyCtrl"], SCREEN_W / 2 + 40, SCREEN_H / 2 + 100, NULL); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2 + 70, SCREEN_H / 2 + 110, ALLEGRO_ALIGN_LEFT, "+"); + al_draw_bitmap(sprites["KeyM"], SCREEN_W / 2 + 78, SCREEN_H / 2 + 100, NULL); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2 + 113, SCREEN_H / 1.3 - 20, ALLEGRO_ALIGN_LEFT, "Toggle Music"); + + al_flip_display(); + + while (help) { + ALLEGRO_EVENT unhelp; + al_wait_for_event(event_queue, &unhelp); + + if (unhelp.type == ALLEGRO_EVENT_KEY_DOWN) { + if (unhelp.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { + help = false; + } + } + } } break; case ALLEGRO_KEY_ESCAPE: - next_state = Exit; + back(); exit_screen = true; break; + case ALLEGRO_KEY_LCTRL: + case ALLEGRO_KEY_RCTRL: + ctrl = true; + break; + } + if (ev.type == ALLEGRO_EVENT_KEY_UP) { + if (ev.keyboard.keycode == ALLEGRO_KEY_LCTRL || ev.keyboard.keycode == ALLEGRO_KEY_RCTRL) { + ctrl = false; + } } - al_clear_to_color(al_map_rgb(0, 0, 0)); redraw(font); al_flip_display(); } } + if (next_state != Exit) { + cont(); + } + al_rest(2.0); } void GameScreen::redraw(ALLEGRO_FONT* font) { - al_draw_bitmap(sprites["Mr. Manager"], 10, 0 + (SCREEN_H / lines.size() * selected), NULL); + al_draw_bitmap(sprites["Mr. Manager"], 80, 0 + (SCREEN_H / lines.size() * selected), NULL); - for (int i = 0; i < lines.size(); i++) { + for (unsigned int i = 0; i < lines.size(); i++) { lines.at(i).draw(); } + + ostringstream score_msg; + score_msg << "Score: " << score; + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W - 90, 0, ALLEGRO_ALIGN_LEFT, score_msg.str().c_str()); + + al_draw_bitmap(sprites["Mr. Man"], SCREEN_W - 90, 20, NULL); + ostringstream catcher_msg; + catcher_msg << " x " << max_catchers - catchers; + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W - 50, 30, ALLEGRO_ALIGN_LEFT, catcher_msg.str().c_str()); + + ostringstream difficulty_msg; + difficulty_msg << "Level: " << difficulty; + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W - 90, 75, ALLEGRO_ALIGN_LEFT, difficulty_msg.str().c_str()); } void GameScreen::back() { diff --git a/TrustFall/TrustFall/game_screen.h b/TrustFall/TrustFall/game_screen.h index 92c6272..a0b61b4 100644 --- a/TrustFall/TrustFall/game_screen.h +++ b/TrustFall/TrustFall/game_screen.h @@ -7,9 +7,14 @@ public: std::map sprites; std::vector lines; int selected; + int max_catchers; + int catchers; + int score; + int difficulty; - GameScreen(std::map _sprites, int _lines); + GameScreen(std::map _sprites); + void reset(int _lines, int _max_catchers, int _difficulty); void run(ALLEGRO_FONT* font); void redraw(ALLEGRO_FONT* font); void back(); diff --git a/TrustFall/TrustFall/line.cpp b/TrustFall/TrustFall/line.cpp index db8ab6b..fece562 100644 --- a/TrustFall/TrustFall/line.cpp +++ b/TrustFall/TrustFall/line.cpp @@ -21,23 +21,27 @@ Line::Line(int _start_x, int _start_y, map _sprites) { } void Line::move() { + if (caught) { + caught = false; + catchers[0] = catchers[1]; + catchers[1] = catchers[2]; + catchers[2] = 0; + } + + for (int i = 0; i < 5; i++) { + employees[i] = employees[i + 1]; + } + employees[5] = (queued) ? 1 : 0; + queued = false; + if (employees[0]) { if (catchers[0]) { - caught = true; - catchers[0] = catchers[1]; - catchers[1] = catchers[0]; - catchers[2] = 0; } else { fall = true; } } - for (int i = 0; i < 4; i++) { - employees[i] = employees[i + 1]; - } - employees[4] = (queued) ? 1 : 0; - queued = false; } void Line::add_employee() { @@ -45,7 +49,7 @@ void Line::add_employee() { } void Line::add_catcher() { - for (int i = 2; i > -1; i--) { + for (int i = 0; i < 3; i++) { if (!catchers[i]) { catchers[i] = 1; break; @@ -56,31 +60,23 @@ void Line::add_catcher() { void Line::draw() { al_draw_bitmap(sprites["Conveyor"], start_x, start_y, NULL); - for (int i = 0; i < 5; i++) { + for (int i = 1; i < 6; i++) { if (employees[i]) { - al_draw_bitmap(sprites["Employee"], start_x + (40 * i), start_y, NULL); + al_draw_bitmap(sprites["Employee"], start_x + (40 * (i-1)), start_y, NULL); } } for (int i = 2; i > -1; i--) { - if (i = 0) { + if (i == 0) { if (caught) { al_draw_bitmap(sprites["EmployeeHappy"], start_x - 40, start_y, NULL); - caught = false; } else if (fall) { - al_draw_bitmap(sprites["EmployeeSad"], start_x - 40, start_y - 55, ALLEGRO_FLIP_VERTICAL); - } - else { - if (catchers[i]) { - al_draw_bitmap(sprites["Mr. Man"], start_x - 40, start_y - 40, NULL); - } + al_draw_bitmap(sprites["EmployeeSad"], start_x - 40, start_y + 55, ALLEGRO_FLIP_VERTICAL); } } - else { - if (catchers[i]) { - al_draw_bitmap(sprites["Mr. Man"], start_x - 40 - (50*(i)), start_y + 40, NULL); - } + if (catchers[i]) { + al_draw_bitmap(sprites["Mr. Man"], start_x - 40 - (50*(i)), start_y + 40, NULL); } } } \ No newline at end of file diff --git a/TrustFall/TrustFall/line.h b/TrustFall/TrustFall/line.h index ab9c6f0..245d335 100644 --- a/TrustFall/TrustFall/line.h +++ b/TrustFall/TrustFall/line.h @@ -15,7 +15,7 @@ public: std::map sprites; int catchers[3]; - int employees[5]; + int employees[6]; bool queued; bool fall; diff --git a/TrustFall/TrustFall/mrmanagerhappy.bmp b/TrustFall/TrustFall/mrmanagerhappy.bmp new file mode 100644 index 0000000000000000000000000000000000000000..0e455a6aa59b075560190ed1ea809f1f743b342a GIT binary patch literal 19322 zcmeHFL2er{5Oe#A+IEr++y{WcgLHV<(*+Li1CxgkfmC3+@W>Dm)L#VX4%(MQV)NOac9)ri)|^hi~J z6n`ySK;_@`m=dN;#5^3Se+v3H6-04=3~|FSig8fEowL-ofXX@kh$hG2c(zK3@v5VT zd|Z8xd9C-_^P0Qf?}!b2w%^r=9Y#FwwdY8-5t^*N=;LFng?|fAEr$p{!UsJWTd7!S zF_uGwN6(1f(uj|BD!i}pPa_WgbaaT!^4%g1zQ#Yrw0;u*RHj5`MSOZRkqi+{Btw=@ zWR|6gWQb@if8oU;%LiwnGh);r<_vfXG2Uv$xjr}@oe`r3v1pjVyR1Qd1fyF-Z)rFQ zIwKzEU^ycnNrHL{f6l(RJq!CAvu+`8IYjsoKIqBVO2tZxu^b{idPelKYp`#@v)A$S zYuO@0?BAO7lnXL5X*G^*RkL_@n27O9`KJ@rl&Fz9s(Bc&`_6EU``?(=r z?v*3U%BSCt^A^WrMlLeXOi>D1zBk8>CU>WEW@eiD-m&s-Sh%IS+& zv@(;(oF7|#IeA>kchAFci+Hx4yYVTx%AU+UcXM0B-6V6*cYM|vls!#ne7|Sd`O2_1 Mur{zZFz*K509nJBZ~y=R literal 0 HcmV?d00001 diff --git a/TrustFall/TrustFall/mrmanagersad.bmp b/TrustFall/TrustFall/mrmanagersad.bmp new file mode 100644 index 0000000000000000000000000000000000000000..1179a25eb6d44ed634a21879ba8044eda15c718d GIT binary patch literal 19322 zcmeHFL2leY40HO5+;i_Ea_ONc5ab=b^_I^kgD4farYXxi<6Vz40d^x(6h+GW{O9fW z^!fKzzWTS`pt{ZxxP3PJRlR`ixN3p8`bcOu^k?K3)^61aX->l2}s7e z4BF$OLPHRjmRc!0jS1db9QQ5{8sY>i6s;AG>tao3&S;L8LbYc2>@iT7G3y_FS4PUo zn~F`!8FCHBoaYrbB`xHw%6a~6n0z0+0D531c6+Hg#mH;#jxW>8J4K(IV!Yq+e(@Kw zca6Wd-s{y{^&XJ@2a%l|a5`$mapG=AG100DrEr|>wB~4xbQ(?B#(-EW{t0l8X~hW= ztwzAetK<_9M&1*=#2`YG_gh4Q6<4%k!MGc*Ym&FDsPQm!=$2-KYz% z;%-JE-i`{HU9nn5A?CzgbQ?Q~yS62>E2C4x$#}?cG9Fs#WOgY|#zTgq^bI$KRyw!~ zm9a(+*6abNu*Rvabz2?Wj>=dg2W#Ung0sv)ex^pX3}12B2`Xc~pMp|GJmUoUs{WpN z@p`I`FQ%ptR|*+?4;|FxTDfATLX<)VN6iescMj$)b?T5bp(h_7f>=lGt-scK?ZAWey)^@e^ze&x*E>5vM zMr@FAMherw^1ZljZ*X-xduC))-aAHK4eQ?U?3h>8>H@BlS?%Oj1-ez5%yGm$m!gb2 z?oy0+YmtxLd)4gO5cQ2dc^13Jtl2XrHP4J7e#~6TRgf1)JTilb9KTk1*?FGHv&TU= vMc!M@Y<^2yW{u~X*|sV2YUa7-JHP7)%$lS +#include +#include "result_screen.h" + +using std::string; +using std::vector; +using std::ostringstream; + +ResultScreen::ResultScreen(std::map _sprites, int _score, int _difficulty) { + score = _score; + difficulty = _difficulty; + + vector menu_options; + menu_options.push_back("Retry"); + menu_options.push_back("To Main Menu"); + menu_options.push_back("Exit"); + menu.activate(menu_options); + + sprites = _sprites; +} + +void ResultScreen::run(ALLEGRO_FONT* font) { + ALLEGRO_EVENT_QUEUE* event_queue = NULL; + event_queue = al_create_event_queue(); + al_register_event_source(event_queue, al_get_keyboard_event_source()); + + redraw(font); + al_flip_display(); + + bool exit_screen = false; + while (!exit_screen) { + ALLEGRO_EVENT ev; + al_wait_for_event(event_queue, &ev); + + if (ev.type == ALLEGRO_EVENT_KEY_DOWN) { + switch (ev.keyboard.keycode) { + case ALLEGRO_KEY_UP: + menu.up(); + break; + case ALLEGRO_KEY_DOWN: + menu.down(); + break; + case ALLEGRO_KEY_ENTER: + cont(); + exit_screen = true; + break; + case ALLEGRO_KEY_ESCAPE: + back(); + exit_screen = true; + break; + } + redraw(font); + al_flip_display(); + } + } +} + +void ResultScreen::redraw(ALLEGRO_FONT * font) { + string manager_sprite = (score > 29) ? "Mr. ManagerHappy" : "Mr. ManagerSad"; + string result_text = (score > 29) ? "Great job! You helped Mr. Manager's team feel more close together!" : "You didn't catch a lot of employees. Try to catch more next time!"; + + al_draw_bitmap(sprites[manager_sprite], SCREEN_W / 2 - 120, SCREEN_H / 2 - 40, NULL); + menu.draw(SCREEN_W / 2, SCREEN_H / 2 - 30, 20.0, font); + ostringstream score_msg; + score_msg << "Final Score: " << score; + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 - 90, ALLEGRO_ALIGN_CENTER, score_msg.str().c_str()); + ostringstream difficulty_msg; + difficulty_msg << "Level: " << difficulty; + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 - 75, ALLEGRO_ALIGN_CENTER, difficulty_msg.str().c_str()); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 - 60, ALLEGRO_ALIGN_CENTER, result_text.c_str()); +} + +void ResultScreen::back() { + next_state = Exit; +} + +void ResultScreen::cont() { + string result = menu.get_selected(); + if(result == "Retry") { + next_state = Gameplay; + } + else if (result == "To Main Menu") { + next_state = Start; + } + else { + next_state = Exit; + } +} diff --git a/TrustFall/TrustFall/result_screen.h b/TrustFall/TrustFall/result_screen.h new file mode 100644 index 0000000..1a314a5 --- /dev/null +++ b/TrustFall/TrustFall/result_screen.h @@ -0,0 +1,18 @@ +#pragma once +#include "cursor.h" +#include "screen.h" + +class ResultScreen : public Screen { +public: + int score; + int difficulty; + Cursor menu; + std::map sprites; + + ResultScreen(std::map _sprites, int _score, int _difficulty); + + void run(ALLEGRO_FONT* font); + void redraw(ALLEGRO_FONT* font); + void back(); + void cont(); +}; \ No newline at end of file diff --git a/TrustFall/TrustFall/small_key_ctrl.bmp b/TrustFall/TrustFall/small_key_ctrl.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d3e0cbfff9e65e8a92916a2152ff268d2aca9175 GIT binary patch literal 2882 zcmeHHF%H5&3_BR%157OJJfaH|3-4fKi1gHWRjsJt-|_-O@YzF*A>tclC~ITz3+;0sM!Z z=u?W*7^&kBs|CQ61k7Et;Smp%hMLGo=8U&fMTz>W|X0mLY|taJ8p5mk>MmWJY3 zMVB#7GJgh&uF{H>J~G16&+x_#ZcrGC_cIqHng$-4DdS^R8Yf4*)g)l8LmZhO-o-v? z0g9Sw-e@(gm7GG9M_yac1B7JHojY>Gt_Y~XnJo9$**j&MWUENl_i}6ig zkINP8HzZqDtDo4OgEG=N|5f$fY#H@EqQV~bhYbS>046L+VHZr;FpvOX!jcqr!GsM1 e2>>Q6NnsaE*f5X)V8W6VcENPpW5$2khy4U$3sSfM literal 0 HcmV?d00001 diff --git a/TrustFall/TrustFall/small_key_h.bmp b/TrustFall/TrustFall/small_key_h.bmp new file mode 100644 index 0000000000000000000000000000000000000000..9c6409cabe499ed9180029892514a971264dc937 GIT binary patch literal 2882 zcmeH{F%H5o3`GqiT!4v%okL_{V&NQYY@Co=l_=pgX^YI4P!>p}_&fgJzl~KjoWs`A zy2p5pd;i)i+ok$rV|F;^oeD98)8$64;(8_=nk}o>S>>2NTNGyi)uuao* z&-*p6{d=v_Zkj(fDIJbwO@q7*r^^lgE3O;k*zHNFTlGkH^D)6=dEcd5uknxXgiq7Y zt=v(Oz#1~