From c4124d27d1e5f61ab6effca514a4e99ab9dd478b Mon Sep 17 00:00:00 2001 From: BraydonKains Date: Fri, 25 Jan 2019 23:51:08 -0500 Subject: [PATCH] Aesthetic stuff and I think that's it actually --- Assignment3Project/Assignment3Project/enums.h | 10 +++- .../Assignment3Project/game.cpp | 3 +- .../Assignment3Project/game_screen.cpp | 22 +++++-- .../Assignment3Project/game_screen.h | 1 + .../Assignment3Project/music_off.bmp | Bin 0 -> 4922 bytes .../Assignment3Project/music_on.bmp | Bin 0 -> 4922 bytes .../Assignment3Project/start_screen.cpp | 56 +++++++++--------- 7 files changed, 56 insertions(+), 36 deletions(-) create mode 100644 Assignment3Project/Assignment3Project/music_off.bmp create mode 100644 Assignment3Project/Assignment3Project/music_on.bmp diff --git a/Assignment3Project/Assignment3Project/enums.h b/Assignment3Project/Assignment3Project/enums.h index c0b0cc2..f960635 100644 --- a/Assignment3Project/Assignment3Project/enums.h +++ b/Assignment3Project/Assignment3Project/enums.h @@ -2,8 +2,8 @@ #define SCREEN_W 640 #define SCREEN_H 480 -#define SCREEN_R_B 600 -#define SCREEN_L_B 40 +#define SCREEN_R_B 560 +#define SCREEN_L_B 80 #define TILE_SIZE 40 #define LEVEL_LEN 120 @@ -41,4 +41,10 @@ struct NewEnemy { int x; Behavior e_type; int when; +}; + +struct InputDelay { + bool input_hit; + int delay_sec; + int max_delay; }; \ No newline at end of file diff --git a/Assignment3Project/Assignment3Project/game.cpp b/Assignment3Project/Assignment3Project/game.cpp index 01ab403..930986f 100644 --- a/Assignment3Project/Assignment3Project/game.cpp +++ b/Assignment3Project/Assignment3Project/game.cpp @@ -13,7 +13,8 @@ void Game::init() { state = Start; sprites.insert(pair("Ship", al_load_bitmap("placeholder.bmp"))); sprites.insert(pair("Enemy", al_load_bitmap("enemy.bmp"))); - + sprites.insert(pair("MusicOn", al_load_bitmap("music_on.bmp"))); + sprites.insert(pair("MusicOff", al_load_bitmap("music_off.bmp"))); al_reserve_samples(4); samples.insert(pair("Theme", al_load_sample("cheesetheme.wav"))); diff --git a/Assignment3Project/Assignment3Project/game_screen.cpp b/Assignment3Project/Assignment3Project/game_screen.cpp index 7b44475..301e310 100644 --- a/Assignment3Project/Assignment3Project/game_screen.cpp +++ b/Assignment3Project/Assignment3Project/game_screen.cpp @@ -91,15 +91,17 @@ void GameScreen::run(ALLEGRO_FONT* font) { NewEnemy next_enemy = enemy_q.back(); enemy_q.pop_back(); - //MapLoad((char*)"level.fmp", 1); + map inputs; + inputs.insert(pair("Fire", InputDelay())); + inputs.insert(pair("Music", InputDelay())); + inputs.insert(pair("Help", InputDelay())); + map_y = TILE_SIZE * LEVEL_LEN; redraw(font); al_flip_display(); - - int fired_counter = 0; - + bool keys[ALLEGRO_KEY_MAX]; for (int i = 0; i < ALLEGRO_KEY_MAX; i++) keys[i] = false; @@ -109,6 +111,11 @@ void GameScreen::run(ALLEGRO_FONT* font) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &ev); if (ev.type == ALLEGRO_EVENT_TIMER) { //Check per frame + //Music toggle + if (keys[KEYCTRL] && keys[KEYM]) { + music = !music; + } + //Ship Movement if (keys[KEYUP]) { if (keys[KEYRIGHT]) { @@ -278,6 +285,13 @@ void GameScreen::redraw(ALLEGRO_FONT* font) { //MapDrawBG(0, map_y, 0, SCREEN_L_B, SCREEN_W - 80, SCREEN_H); objects.draw_objects(); + + ostringstream score_msg; + score_msg << "Score: " << score; + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_R_B + 2, 0, ALLEGRO_ALIGN_LEFT, score_msg.str().c_str()); + + string music_img = (music) ? "MusicOn" : "MusicOff"; + al_draw_bitmap(sprites[music_img], SCREEN_R_B + 10, 90, NULL); } void GameScreen::back() { diff --git a/Assignment3Project/Assignment3Project/game_screen.h b/Assignment3Project/Assignment3Project/game_screen.h index fdbbe7b..efc6522 100644 --- a/Assignment3Project/Assignment3Project/game_screen.h +++ b/Assignment3Project/Assignment3Project/game_screen.h @@ -33,4 +33,5 @@ public: private: void play(ALLEGRO_SAMPLE_INSTANCE* x); void build_enemy_queue(); + void set_delays(std::map inputs); }; \ No newline at end of file diff --git a/Assignment3Project/Assignment3Project/music_off.bmp b/Assignment3Project/Assignment3Project/music_off.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3ef124e3b241fc17e80576c99637fb89ff402d0f GIT binary patch literal 4922 zcmeH{F%H5o3`GM+fQ6lfi32cpVPfGNY~45=Hw#t*Ra7_M7C1&osgyLezus#-bhwA zDRuMCq&{9Qb?`1qTYGELrd}ZZ#*49H_v4?GNXCKgRZakpQS2%$JSLKHfCH5kj1{{| z3y+Cp9N<7@1!Kjo(!ygR83#B}S;1JbtF-W#NX7vUw5t5dOYaZVR$o`+)YP@SVSQ0; o$OkB{24UOQOl=Ftv{H?e=G{qcP8NY#Eyh{|NZkV4nSVNgCl1R#?f?J) literal 0 HcmV?d00001 diff --git a/Assignment3Project/Assignment3Project/music_on.bmp b/Assignment3Project/Assignment3Project/music_on.bmp new file mode 100644 index 0000000000000000000000000000000000000000..9d437154698f93b0fc105bde193e67049b0db005 GIT binary patch literal 4922 zcmeH{F%H5o3`GM+fQ6lfi32cpVPfGNY;2s4n-!}8%d#CODvk$eq_pe*1|J1GTb*pjlEjK`JU>rx%1(g7e=VoXy7om|{ z3Jv2jXbe|E1Gp-*H@5`s$~B->u3@latE<(YR0&;8whfXiK~jNTc5HQ3a&sot`*CG5 zRcMXp0r8tbbFhX2GO?vK6nFMFqi9QO-+PwHRH3ym7t?aVK&(X%=(7hSLJLt$ zluEYEhN^)rQ07rv`&8-{6k864W?2|$Y4%l0XkUt&rlM7+yC~7_h*BU!mux+Bitdqb YWFp$|bXv;jPT_Vepl!pl`d2sb0yF=ZlmGw# literal 0 HcmV?d00001 diff --git a/Assignment3Project/Assignment3Project/start_screen.cpp b/Assignment3Project/Assignment3Project/start_screen.cpp index 9b52a01..cc6506c 100644 --- a/Assignment3Project/Assignment3Project/start_screen.cpp +++ b/Assignment3Project/Assignment3Project/start_screen.cpp @@ -70,36 +70,34 @@ void StartScreen::redraw(ALLEGRO_FONT* font) { //Instructions - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 10, ALLEGRO_ALIGN_CENTER, "This is going to be a shootemup."); - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 20, ALLEGRO_ALIGN_CENTER, "Eventually."); - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 30, ALLEGRO_ALIGN_CENTER, "We'll see."); - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 40, ALLEGRO_ALIGN_CENTER, "idek."); - - /* + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2, ALLEGRO_ALIGN_CENTER, "Travel across the reaches of space"); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 10, ALLEGRO_ALIGN_CENTER, "to kill all the red ships!"); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 20, ALLEGRO_ALIGN_CENTER, "Red is a bad colour that must be eradicated."); + //al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 40, ALLEGRO_ALIGN_CENTER, "idek."); + //Keys and their associated functions - 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 - "); - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 8 + 150, SCREEN_H / 1.3 - 15, ALLEGRO_ALIGN_LEFT, "Place Employee"); - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 8 + 150, SCREEN_H / 1.3 - 25, ALLEGRO_ALIGN_LEFT, "Select Menu Item"); - - al_draw_bitmap(sprites["KeyEsc"], SCREEN_W / 8 + 20, SCREEN_H / 2 + 140, NULL); - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 8 + 68, SCREEN_H / 2 + 150, ALLEGRO_ALIGN_LEFT, "Exit Game"); - - al_draw_bitmap(sprites["KeyCtrl"], SCREEN_W / 2 + 40, SCREEN_H / 2 + 60, NULL); - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2 + 70, SCREEN_H / 1.5 - 10, ALLEGRO_ALIGN_LEFT, "+"); - al_draw_bitmap(sprites["KeyH"], SCREEN_W / 2 + 78, 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, "Help 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_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 / 12, SCREEN_H / 1.5 - 10, ALLEGRO_ALIGN_LEFT, "WASD or Arrows - Move ship"); + + //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 / 12, SCREEN_H / 1.3 - 20, ALLEGRO_ALIGN_LEFT, "Spacebar - Shoot"); + //al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 8 + 150, SCREEN_H / 1.3 - 15, ALLEGRO_ALIGN_LEFT, "Place Emplo"); + //al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 8 + 150, SCREEN_H / 1.3 - 25, ALLEGRO_ALIGN_LEFT, "Select Menu Item"); + + //al_draw_bitmap(sprites["KeyEsc"], SCREEN_W / 8 + 20, SCREEN_H / 2 + 140, NULL); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 12, SCREEN_H / 2 + 150, ALLEGRO_ALIGN_LEFT, "Esc - Exit Game"); + + //al_draw_bitmap(sprites["KeyCtrl"], SCREEN_W / 2 + 40, SCREEN_H / 2 + 60, NULL); + //al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2 + 70, SCREEN_H / 1.5 - 10, ALLEGRO_ALIGN_LEFT, "+"); + //al_draw_bitmap(sprites["KeyH"], SCREEN_W / 2 + 78, 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, "Ctrl + H - Help 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, "Ctrl + M - Toggle Music"); + al_draw_text(font, al_map_rgb(255, 255, 255), 0, SCREEN_H - 10, ALLEGRO_ALIGN_LEFT, "Copyright 2019 Braydon Kains"); }