From eb3f1163aa74fa6b7589d625c23e90bdb086d07a Mon Sep 17 00:00:00 2001 From: BraydonKains Date: Wed, 9 Jan 2019 20:14:37 -0500 Subject: [PATCH] getting all changes off laptop --- .../Assignment3Project/game.cpp | 81 ++---------------- Assignment3Project/Assignment3Project/game.h | 1 + .../Assignment3Project/game_screen.cpp | 3 +- .../Assignment3Project/main.cpp | 42 +++++++++ .../Assignment3Project/placeholder.bmp | Bin 0 -> 19322 bytes .../Assignment3Project/screen.h | 3 + .../Assignment3Project/start_screen.cpp | 40 ++------- Untitled.xcf | Bin 0 -> 2109 bytes 8 files changed, 61 insertions(+), 109 deletions(-) create mode 100644 Assignment3Project/Assignment3Project/placeholder.bmp create mode 100644 Untitled.xcf diff --git a/Assignment3Project/Assignment3Project/game.cpp b/Assignment3Project/Assignment3Project/game.cpp index ce9d1eb..30b7390 100644 --- a/Assignment3Project/Assignment3Project/game.cpp +++ b/Assignment3Project/Assignment3Project/game.cpp @@ -1,7 +1,6 @@ #include "game.h" #include "start_screen.h" #include "game_screen.h" -#include "result_screen.h" using std::string; using std::map; @@ -14,31 +13,12 @@ Game::Game() { void Game::init() { score = 0; 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("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"))); - sprites.insert(pair("MusicOn", al_load_bitmap("music_on.bmp"))); - sprites.insert(pair("MusicOff", al_load_bitmap("music_off.bmp"))); + //sprites.insert(pair("Title", al_load_bitmap("logo.bmp"))); + + + //al_reserve_samples(4); + //samples.insert(pair("Theme", al_load_sample("rasputin.wav"))); - al_reserve_samples(4); - samples.insert(pair("Theme", al_load_sample("rasputin.wav"))); - samples.insert(pair("Move", al_load_sample("move.wav"))); - samples.insert(pair("Catch", al_load_sample("catch.wav"))); - samples.insert(pair("Fall", al_load_sample("fall.wav"))); - samples.insert(pair("Place", al_load_sample("place.wav"))); - samples.insert(pair("LevelUp", al_load_sample("level.wav"))); font = al_create_builtin_font(); } @@ -50,56 +30,7 @@ void Game::reset() { //Run the game state machine void Game::run() { //Load screens - - int difficulty = 1; //Difficulty to run - bool EXTREME_ON = false; //Flag for EXTREME easter egg - while (state != Exit) { - al_clear_to_color(al_map_rgb(0, 0, 0)); - switch (state) { - case Start: - start_screen.run(font); - if (start_screen.next_state == EXTREME) { - EXTREME_ON = true; - state = Hard; - } - else { - state = start_screen.next_state; - } - break; - //The same set of code will be run for any difficulty state - case Easy: - case Medium: - case Hard: - //But we need to check once here whether the difficulty value needs to be adjusted - switch (state) { - case Medium: - difficulty = 3; - result_screen.prev_state = Medium; - break; - case Hard: - difficulty = 5; - result_screen.prev_state = Hard; - break; - } - if (EXTREME_ON) { - game_screen.reset(5, 5, difficulty); //If the EXTREME easter egg is enabled, the game will be run with 5 lines on hard mode - } - else { - game_screen.reset(3, 5, difficulty); - } - EXTREME_ON = false; - game_screen.run(font); - state = game_screen.next_state; - break; - case End: - //Send proper finishing values for this game to the result screen - result_screen.score = game_screen.score; - result_screen.difficulty = game_screen.difficulty; - result_screen.run(font); - state = result_screen.next_state; - break; - } - } + //Garbage collection map::iterator it; diff --git a/Assignment3Project/Assignment3Project/game.h b/Assignment3Project/Assignment3Project/game.h index 7e37d30..da5eda2 100644 --- a/Assignment3Project/Assignment3Project/game.h +++ b/Assignment3Project/Assignment3Project/game.h @@ -11,6 +11,7 @@ #include #include "enums.h" +#include "screen.h" //Game state machine, contains data global to game class Game { diff --git a/Assignment3Project/Assignment3Project/game_screen.cpp b/Assignment3Project/Assignment3Project/game_screen.cpp index 5668a14..6554a5d 100644 --- a/Assignment3Project/Assignment3Project/game_screen.cpp +++ b/Assignment3Project/Assignment3Project/game_screen.cpp @@ -60,7 +60,7 @@ void GameScreen::run(ALLEGRO_FONT* font) { for (int i = 0; i < ALLEGRO_KEY_MAX; i++) keys[i] = false; al_start_timer(timer); - bool exit_screen; + bool exit_screen = false; while (!exit_screen) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &ev); @@ -118,6 +118,7 @@ void GameScreen::run(ALLEGRO_FONT* font) { case ALLEGRO_KEY_RCTRL: keys[KEYCTRL] = false; break; + } } //Global refresh al_clear_to_color(al_map_rgb(0, 0, 0)); diff --git a/Assignment3Project/Assignment3Project/main.cpp b/Assignment3Project/Assignment3Project/main.cpp index e69de29..36bd308 100644 --- a/Assignment3Project/Assignment3Project/main.cpp +++ b/Assignment3Project/Assignment3Project/main.cpp @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "game.h" + +int main() { + if (!al_init()) { + fprintf(stderr, "Could not initialize Allegro!"); + } + if (!al_init_image_addon()) { + fprintf(stderr, "Could not initialize image addon!"); + } + if (!al_init_acodec_addon()) { + fprintf(stderr, "Could not initialize audio codec addon!"); + } + if (!al_install_audio()) { + fprintf(stderr, "Could not install audio!"); + } + if (!al_init_font_addon()) { + fprintf(stderr, "Could not initialize font addon!"); + } + if (!al_install_keyboard()) { + fprintf(stderr, "Could not install keyboard!"); + } + + ALLEGRO_DISPLAY* display = NULL; + display = al_create_display(SCREEN_W, SCREEN_H); + + Game main_game; + main_game.init(); + main_game.run(); + + al_uninstall_keyboard(); + al_uninstall_audio(); + + return 0; +} \ No newline at end of file diff --git a/Assignment3Project/Assignment3Project/placeholder.bmp b/Assignment3Project/Assignment3Project/placeholder.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a8e1408800361be449692413a68d9fd123c63793 GIT binary patch literal 19322 zcmeI1!A`?45JUrC!JRuF(F+HJg!m3_-1_riHO1OG!SQ-$(~UKe(r%pH>AZ2&OHS|S zx9M`6)8|(@Kd$G)^mJLD(*5U``J5M~>Gb;f{a3esKNgKYTSw6!{Bnz?>3(p=Y_AEX ztto4UE!sE~U13R+F$IREH72r#K;0V+Sq-2ch=Z*6-Z>Egxzl>@*nN?EU7P0ag={iy z8{Qw;<`*!%Co;e;LSi3egj1M?H!{p9PRI`#=Mk*rfef~Ymct^W-MQ$YkX_9Ah}w~T zd^xIGkR5GNnh7ugCcp%k025#WOn?b60Vco%m;e)C0!)AjFaajO1egF5U;<2l2`~XB zFlYklE$yIWD_HrJ^vb>AmNM*I499l^RKSjnyb3!ias_rgBv1X*g%g3A@-4@p5|ZFG{xr2!9KsSl}*$kGFxSBe8` z3$nC<<(10tx*J(K0rE;&r@9YWnnCeOP1m{uS^9zSO2Hj!EwZ#^=ap(f>LL*7YLizs zAEhR5-YM>H _sprites) { vector menu_options; - menu_options.push_back("Easy"); //Select Difficulty - menu_options.push_back("Medium"); - menu_options.push_back("Hard"); + menu_options.push_back("Start"); //Start game menu_options.push_back("Quit"); //Quit game menu.activate(menu_options); @@ -44,13 +42,8 @@ void StartScreen::run(ALLEGRO_FONT * font) { menu.down(); break; case ALLEGRO_KEY_SPACE: - if (ctrl) { //If the ctrl key is held regardless of option, they will enter EXTREME easter egg mode - next_state = EXTREME; - } - else { - cont(); //Otherwise select the menu item - } - + //Select item + cont(); exit_screen = true; break; case ALLEGRO_KEY_ESCAPE: @@ -58,19 +51,10 @@ void StartScreen::run(ALLEGRO_FONT * font) { back(); exit_screen = true; break; - case ALLEGRO_KEY_LCTRL: - case ALLEGRO_KEY_RCTRL: - ctrl = true; //ctrl is held down - break; } redraw(font); al_flip_display(); } - if (ev.type == ALLEGRO_EVENT_KEY_UP) { - if (ev.keyboard.keycode == ALLEGRO_KEY_LCTRL || ev.keyboard.keycode == ALLEGRO_KEY_RCTRL) { - ctrl = false; //ctrl is released - } - } } //Garbage collection @@ -78,12 +62,8 @@ void StartScreen::run(ALLEGRO_FONT * font) { } void StartScreen::redraw(ALLEGRO_FONT* font) { - al_draw_bitmap(sprites["Title"], SCREEN_W / 2 - 240, 20, NULL); //logo - al_draw_bitmap(sprites["Mr. Manager"], SCREEN_W / 2 - 40, 120, NULL); //manager - for (int i = 1; i < 7; i++) { - al_draw_bitmap(sprites["Mr. Man"], SCREEN_W / 8 * i + 14, SCREEN_H / 2 - 30, NULL); //army of catchers - } - + //al_draw_bitmap(sprites["Title"], SCREEN_W / 2 - 240, 20, NULL); //logo + //Instructions al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 10, ALLEGRO_ALIGN_CENTER, "Mr. Manager wants to run a teambuilding exercise for his employees."); al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 20, ALLEGRO_ALIGN_CENTER, "Help Mr.Manager place his 5 catchers at the end of his"); @@ -121,14 +101,8 @@ void StartScreen::back() { } void StartScreen::cont() { - if (menu.get_selected() == "Easy") { - next_state = Easy; - } - else if (menu.get_selected() == "Medium") { - next_state = Medium; - } - else if (menu.get_selected() == "Hard") { - next_state = Hard; + if (menu.get_selected() == "Start") { + next_state = Gameplay; } else { next_state = Exit; diff --git a/Untitled.xcf b/Untitled.xcf new file mode 100644 index 0000000000000000000000000000000000000000..75c20dd5defa297e3ce45bff6a5688bb0f899f50 GIT binary patch literal 2109 zcmeH{+iuf95QZmCnu8tZoI+^}+m=E?NlBobK}f9-;sS{m;39P#*CL6l#D(;#JO$6e z18~o4aEo{chJWLAv6{}|Txuyo4_hC_E0VodVK%HG)RhHg*1_QM15`Onk3$9gBbPK zvUa=9OK%(;jb;gy?;<4)mG8vRHOY_O;ET6}O215WPB9FvYrLYdsj<-5(m1cNt#J`7 z_lqS1kbBGZHxLMPxHg zWj{rh=mIe>Py))lO$MjHDcGwxViKH$-TDhGsHoO2a*axgOI)F{;xd=0qPW5Zs?OP_ z+MM%LpR+}ab2e#*b99rlbc-`|o6~d$cf5tF>}MAJIDn^ootX$y1Uo^ovOgsJ}GoFN@lfnnV4Ws6Pw!mq-2CsK0`& zKcmh6%Nk3(OzXT#0v&Lk*Jy<|=p1j-S-youIcjXQL3m+QFG4cu*q g{`LG5dWVb_kXaiU&Lh(nGHxQjzvsulV?!x@1<6qMlmGw# literal 0 HcmV?d00001