From 4ae3a615c23fecaeec4675efdba9e82c2a1b0369 Mon Sep 17 00:00:00 2001 From: Braydon Kains Date: Thu, 3 Jan 2019 04:31:55 -0500 Subject: [PATCH] Finished Line object and all drawing mechanics for it --- TrustFall/TrustFall/BigMrManager.bmp | Bin 0 -> 19322 bytes TrustFall/TrustFall/TrustFall.vcxproj | 2 + TrustFall/TrustFall/TrustFall.vcxproj.filters | 6 ++ TrustFall/TrustFall/catcher.cpp | 9 ++ TrustFall/TrustFall/catcher.h | 9 ++ TrustFall/TrustFall/conveyor.bmp | Bin 0 -> 52922 bytes TrustFall/TrustFall/cursor.cpp | 3 +- TrustFall/TrustFall/employee.bmp | Bin 0 -> 4922 bytes TrustFall/TrustFall/employee.cpp | 11 +++ TrustFall/TrustFall/employee.h | 9 ++ TrustFall/TrustFall/employee_happy.bmp | Bin 0 -> 4922 bytes TrustFall/TrustFall/employee_sad.bmp | Bin 0 -> 4922 bytes TrustFall/TrustFall/game.cpp | 16 +++- TrustFall/TrustFall/game_screen.cpp | 8 +- TrustFall/TrustFall/game_screen.h | 5 +- TrustFall/TrustFall/line.cpp | 89 ++++++++++++++++++ TrustFall/TrustFall/line.h | 30 ++++++ TrustFall/TrustFall/start_screen.cpp | 4 +- 18 files changed, 193 insertions(+), 8 deletions(-) create mode 100644 TrustFall/TrustFall/BigMrManager.bmp create mode 100644 TrustFall/TrustFall/catcher.cpp create mode 100644 TrustFall/TrustFall/catcher.h create mode 100644 TrustFall/TrustFall/conveyor.bmp create mode 100644 TrustFall/TrustFall/employee.bmp create mode 100644 TrustFall/TrustFall/employee.cpp create mode 100644 TrustFall/TrustFall/employee.h create mode 100644 TrustFall/TrustFall/employee_happy.bmp create mode 100644 TrustFall/TrustFall/employee_sad.bmp create mode 100644 TrustFall/TrustFall/line.cpp create mode 100644 TrustFall/TrustFall/line.h diff --git a/TrustFall/TrustFall/BigMrManager.bmp b/TrustFall/TrustFall/BigMrManager.bmp new file mode 100644 index 0000000000000000000000000000000000000000..f1bbfa8a0da5cdca9593226c0403b36f9e19501d GIT binary patch literal 19322 zcmeH_!EPKe3`3{=ir#zgN958&QK0B|^wwK`K3PO9@D>CO*&ff1cN`!ahNdV{+LxcN zKemsb*W2fx+wZS`zn``*AN+QE|N1R{gV?s0@4x^4$JxK1vqGbLJK2vJb2s{Aao=_e zW{e`Qc}&sVSgOE?`X@2QcXWT3dGm5|#dmAMKU9LggVZPvY4CSt1O8zborH{QUaO%# z@bP)sx138~Ilp^Vo=n++%6^>h<#tkba8;bV>_BBd&dkFuoGpV{TgJ7Ml-=BGZI?_& zYFuCCYbQ~M5sXgd(y4O9Jfl4|#mXBy*UgN+#Rz{*vF^L>JK~$>Jo$Z_9lMO=XV1v_ znM-jfm7kX>Cn~?rnA#Evw3#Q6-r?W|w>wmDkC;S5neoDK&;66PIjp?> zd*cojJAYL=#yMnodS>)aL!UAp=ir>lb2jp|IDA+|XJTrIsUcPknOf|e+k99>XJTrI zsUcPknOf|e+k99>XJTrIsUcPknOf|e+k99>XJTrIsUcPknOf|e+k99>XJTrIsUcPk znOf|e+k99>XJTrIsUcPknOf|e+kDDZ(aUMduThoJIDb0q<&){sOHH1X!qlp>*OteXY^H>xQ_D5IOUP|byK<7oL+fl zoaZrl-8}5B8Zr)Na@AD9f4nJ(wixD@2CkXJ9l4Lsj{ yuaj4kIz}(5TVn+tR998(14y8(15N4ZH(9kdk%) literal 0 HcmV?d00001 diff --git a/TrustFall/TrustFall/TrustFall.vcxproj b/TrustFall/TrustFall/TrustFall.vcxproj index fc3ad9b..8209fe7 100644 --- a/TrustFall/TrustFall/TrustFall.vcxproj +++ b/TrustFall/TrustFall/TrustFall.vcxproj @@ -131,6 +131,7 @@ + @@ -138,6 +139,7 @@ + diff --git a/TrustFall/TrustFall/TrustFall.vcxproj.filters b/TrustFall/TrustFall/TrustFall.vcxproj.filters index b9d8f93..ad87e00 100644 --- a/TrustFall/TrustFall/TrustFall.vcxproj.filters +++ b/TrustFall/TrustFall/TrustFall.vcxproj.filters @@ -45,6 +45,9 @@ Source Files\ScreensImplement + + Source Files\ScreensImplement + @@ -62,5 +65,8 @@ Header Files\Screens + + Header Files\Screens + \ No newline at end of file diff --git a/TrustFall/TrustFall/catcher.cpp b/TrustFall/TrustFall/catcher.cpp new file mode 100644 index 0000000..3831755 --- /dev/null +++ b/TrustFall/TrustFall/catcher.cpp @@ -0,0 +1,9 @@ +#include "catcher.h" + +Catcher::Catcher(int _position) { + position = _position; +} + +void Catcher::move_up() +{ +} diff --git a/TrustFall/TrustFall/catcher.h b/TrustFall/TrustFall/catcher.h new file mode 100644 index 0000000..0ad20af --- /dev/null +++ b/TrustFall/TrustFall/catcher.h @@ -0,0 +1,9 @@ +#pragma once +class Catcher { +public: + int position; + + Catcher(int _position); + + void move_up(); +}; \ No newline at end of file diff --git a/TrustFall/TrustFall/conveyor.bmp b/TrustFall/TrustFall/conveyor.bmp new file mode 100644 index 0000000000000000000000000000000000000000..43cabfc37f92a3598023122b0e21496b02c14839 GIT binary patch literal 52922 zcmeH{L5^fa3`84F!Ja*5K(k?mgg6H~b{uUE!3ns_V6{~tS2)u@t%QH8=ECvIz5Cl(G_T4I0&_^?7Z^Pli{{l2+PyI~8K(0QrZ3cIs+&B>4gwQG(=v=6 zOm&lo=h}TJnqinu#;?lMr;?7|WCwu}o~j0;2bFa6_FTJ9L^BN2(d-vB>T{t^&$5F+ zVslY|(Sr+hdVa3m$DtX9X&U^xKz*(a_X^oT;2z9%2BQbphI_?x?LG_5Fih{KUdpJ? zk|&5{2Z2CkDTL93B~K7N*Y1PR48t^xyc$xURohJ`I|$s6tp0}4gH_v2_guSAK{E`~ z+q{k6)TiNmm&y(TN1^j&v3n78v6!B^bvwuo0!N|qWwCn^bg`J8x^+9q4gyD^^JTGn z5p=Pbp1O5A$PNNWq4Q<2dl7W8n4Y?IJID?KN1^j&v3n78v6!B^bvwuo0!N|qWwCn^ zbg`J8x^+9q4gyD^^JTGn5p=Pbp1O5A$PNNWq4Q<2dl7W8n4Y?IJID?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b/TrustFall/TrustFall/cursor.cpp @@ -4,6 +4,7 @@ #include #include "cursor.h" +#include "line.h" using std::string; using std::vector; @@ -99,4 +100,4 @@ template string Cursor::get_selected(); template void Cursor::update_selector(); vector Cursor::get_item_strings() { return items; -} +} \ No newline at end of file diff --git a/TrustFall/TrustFall/employee.bmp b/TrustFall/TrustFall/employee.bmp new file mode 100644 index 0000000000000000000000000000000000000000..f35a8a0d1a6bcb11b57e31a95253273f38d69b5b GIT binary patch literal 4922 zcmeH@F%H5o3`GM+fQ6lfi32cpVPfGNY;2s4n}OAWWtkVNlG6nxQd;*p->=GWIc>|h z9`d}&K7977>_-0Fl(Iigdj#?r&e!|5p8HsDqo`lVcumYpaP*yvU!+KLNF{T@I#^VrhaV1Cfj zpT{!@HPWO&1;Qpe9fAsk8fj9X0$~%K4nYM%jWj7xflzhQwM)4amP>70uEs7x7fgPl z0%20*;;2CAg2_)*AWVu}92E#%F!@01N{d24gALq Fya8&QeT4u3 literal 0 HcmV?d00001 diff --git a/TrustFall/TrustFall/employee.cpp b/TrustFall/TrustFall/employee.cpp new file mode 100644 index 0000000..69382ae --- /dev/null +++ b/TrustFall/TrustFall/employee.cpp @@ -0,0 +1,11 @@ +#include "employee.h" + +Employee::Employee(int _line) { + position = 6; +} + +void Employee::move() { + position -= 1; +} + + diff --git a/TrustFall/TrustFall/employee.h b/TrustFall/TrustFall/employee.h new file mode 100644 index 0000000..90337cc --- /dev/null +++ b/TrustFall/TrustFall/employee.h @@ -0,0 +1,9 @@ +#pragma once +class Employee { +public: + int position; + + Employee(int _line); + + void move(); +}; \ No newline at end of file diff --git a/TrustFall/TrustFall/employee_happy.bmp b/TrustFall/TrustFall/employee_happy.bmp new file mode 100644 index 0000000000000000000000000000000000000000..61daded8f018fcffd9bdd32e8a922a3c8210ba8a GIT binary patch literal 4922 zcmeH@F%H5o3`GM+fQ6lfi32cpVPfGNY;2s4n}OAW6(uiLDysv+ky6~}|NV=H%W0d& z^N{CF?%{J+X*crcCZ+vxx+9RsaK7HZb?@)m7QPlcMy_NUU1zH`yv3byxg8@A<}QDY z5eWTR`2>tWn7jNnMj-TOcE3T5$% zmY>cw{*m3n%^vve-auAT|&ihz?;qTq4(rsP zo4hab?B35JZF+uRrL^6@o*u}nJD#tf`rF^7FMP~)oLtFty1`a$c#Q|+tQ{i|T35Wr z2!!!0I{_mQT35Wr2!!!0I{_mQT9?$0#%bvg)F4!g7AQlg7A;VQP%X9)Wp-@Wsl`=x z5tgzD!3czrl+ue42up8-URwt=>Rwt@fNz!O=AiFp73 literal 0 HcmV?d00001 diff --git a/TrustFall/TrustFall/game.cpp b/TrustFall/TrustFall/game.cpp index 1c9e89a..368ccc8 100644 --- a/TrustFall/TrustFall/game.cpp +++ b/TrustFall/TrustFall/game.cpp @@ -1,5 +1,6 @@ #include "game.h" #include "start_screen.h" +#include "game_screen.h" using std::string; using std::map; @@ -13,10 +14,14 @@ void Game::init() { state = Start; 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("MrManager.bmp"))); + sprites.insert(pair("Mr. Manager", al_load_bitmap("BigMrManager.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"))); + font = al_create_builtin_font(); } @@ -26,13 +31,18 @@ void Game::reset() { } void Game::run() { + StartScreen start_screen(sprites); + GameScreen game_screen(sprites); while (state != Exit) { switch (state) { case Start: - StartScreen start_screen(sprites); start_screen.run(font); state = start_screen.next_state; break; + case Gameplay: + game_screen.run(font); + state = game_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 59c318e..7ea626b 100644 --- a/TrustFall/TrustFall/game_screen.cpp +++ b/TrustFall/TrustFall/game_screen.cpp @@ -6,8 +6,14 @@ using std::vector; using std::string; -GameScreen::GameScreen(std::map _sprites) { +GameScreen::GameScreen(std::map _sprites, int _lines) { sprites = _sprites; + + for (int i = 0; i < _lines; i++) { + Line new_line(SCREEN_W-220, SCREEN_H/_lines * i, sprites); + } + + selected = 0; } void GameScreen::run(ALLEGRO_FONT * font) { diff --git a/TrustFall/TrustFall/game_screen.h b/TrustFall/TrustFall/game_screen.h index ece3708..984fd21 100644 --- a/TrustFall/TrustFall/game_screen.h +++ b/TrustFall/TrustFall/game_screen.h @@ -1,12 +1,15 @@ #pragma once +#include "line.h" #include "screen.h" #include "cursor.h" class GameScreen : public Screen { public: std::map sprites; + std::vector lines; + int selected; - GameScreen(std::map _sprites); + GameScreen(std::map _sprites, int _lines); void run(ALLEGRO_FONT* font); void redraw(ALLEGRO_FONT* font); diff --git a/TrustFall/TrustFall/line.cpp b/TrustFall/TrustFall/line.cpp new file mode 100644 index 0000000..ac88528 --- /dev/null +++ b/TrustFall/TrustFall/line.cpp @@ -0,0 +1,89 @@ +#include "line.h" + +using std::map; +using std::string; + +Line::Line(int _start_x, int _start_y, map _sprites) { + start_x = _start_x; + start_y = _start_y; + + sprites = _sprites; + + queued = false; + fall = false; + + for (int i = 0; i < 3; i++) { + catchers[i] = 0; + } + for (int i = 0; i < 5; i++) { + employees[i] = 0; + } +} + +void Line::move() { + if (caught) { + caught = false; + catchers[0] = catchers[1]; + catchers[1] = catchers[0]; + catchers[2] = 0; + } + + if (employees[0]) { + if (catchers[0]) { + caught = true; + } + 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() { + queued = true; +} + +void Line::add_catcher() { + for (int i = 2; i > -1; i--) { + if (!catchers[i]) { + catchers[i] = 1; + break; + } + } +} + +void Line::draw() { + al_draw_bitmap(sprites["Conveyor"], start_x, start_y, NULL); + + for (int i = 0; i < 5; i++) { + if (employees[i]) { + al_draw_bitmap(sprites["Employee"], start_x + (40 * i), start_y, NULL); + } + } + + for (int i = 2; i > -1; i++) { + if (i = 0) { + if (caught) { + al_draw_bitmap(sprites["EmployeeHappy"], start_x - 40, start_y, NULL); + al_draw_bitmap(sprites["MrMan"], start_x - 40, start_y - 40, NULL); + } + 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["MrMan"], start_x - 40, start_y - 40, NULL); + } + } + } + else { + if (catchers[i]) { + al_draw_bitmap(sprites["MrMan"], start_x - 40 - (50*(i+1)), start_y - 40, NULL); + } + } + } +} \ No newline at end of file diff --git a/TrustFall/TrustFall/line.h b/TrustFall/TrustFall/line.h new file mode 100644 index 0000000..ab9c6f0 --- /dev/null +++ b/TrustFall/TrustFall/line.h @@ -0,0 +1,30 @@ +#pragma once +#include +#include +#include +#include + +#include "catcher.h" +#include "employee.h" + +class Line { +public: + float start_x; + float start_y; + + std::map sprites; + + int catchers[3]; + int employees[5]; + + bool queued; + bool fall; + bool caught; + + Line(int _start_x, int _start_y, std::map _sprites); + + void move(); + void draw(); + void add_employee(); + void add_catcher(); +}; \ No newline at end of file diff --git a/TrustFall/TrustFall/start_screen.cpp b/TrustFall/TrustFall/start_screen.cpp index 9d5f3b7..25709d3 100644 --- a/TrustFall/TrustFall/start_screen.cpp +++ b/TrustFall/TrustFall/start_screen.cpp @@ -54,9 +54,9 @@ void StartScreen::run(ALLEGRO_FONT * font) { void StartScreen::redraw(ALLEGRO_FONT* font) { al_draw_bitmap(sprites["Title"], 0, 20, NULL); - al_draw_bitmap(sprites["Mr. Manager"], SCREEN_W / 2 - 24, 150, NULL); + al_draw_bitmap(sprites["Mr. Manager"], SCREEN_W / 2 - 40, 120, NULL); for (int i = 1; i < 7; i++) { - al_draw_bitmap(sprites["Mr. Man"], SCREEN_W / 8 * i + 14, SCREEN_H / 2 - 40, NULL); + al_draw_bitmap(sprites["Mr. Man"], SCREEN_W / 8 * i + 14, SCREEN_H / 2 - 30, NULL); } al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 20, ALLEGRO_ALIGN_CENTER, "Mr. Manager wants to run a teambuilding exercise for his employees.");