diff --git a/TrustFall/TrustFall/TrustFall.vcxproj b/TrustFall/TrustFall/TrustFall.vcxproj index 86edf0c..d714a6a 100644 --- a/TrustFall/TrustFall/TrustFall.vcxproj +++ b/TrustFall/TrustFall/TrustFall.vcxproj @@ -22,32 +22,32 @@ 15.0 {C6900ECF-254F-4751-A968-DDA699CCD5A6} TrustFall - 10.0.17134.0 + 10.0 Application true - v141 + v142 MultiByte Application false - v141 + v142 true MultiByte Application true - v141 + v142 MultiByte Application false - v141 + v142 true MultiByte @@ -144,9 +144,6 @@ true - - - @@ -166,16 +163,19 @@ + + + - - + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + \ No newline at end of file diff --git a/TrustFall/TrustFall/TrustFall.vcxproj.filters b/TrustFall/TrustFall/TrustFall.vcxproj.filters index 0f73592..7c73b60 100644 --- a/TrustFall/TrustFall/TrustFall.vcxproj.filters +++ b/TrustFall/TrustFall/TrustFall.vcxproj.filters @@ -32,9 +32,6 @@ {b26b82a2-f4cd-444a-923f-82aad7c96345} - - - Source Files @@ -84,4 +81,7 @@ Header Files\Screens + + + \ No newline at end of file diff --git a/TrustFall/TrustFall/customtheme.wav b/TrustFall/TrustFall/customtheme.wav new file mode 100644 index 0000000..32a1e3b Binary files /dev/null and b/TrustFall/TrustFall/customtheme.wav differ diff --git a/TrustFall/TrustFall/game.cpp b/TrustFall/TrustFall/game.cpp index 743e5cc..fe25113 100644 --- a/TrustFall/TrustFall/game.cpp +++ b/TrustFall/TrustFall/game.cpp @@ -33,13 +33,16 @@ void Game::init() { sprites.insert(pair("MusicOff", al_load_bitmap("music_off.bmp"))); 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"))); + themes.insert(pair("Rasputin", al_load_sample("rasputin.wav"))); + themes.insert(pair("Guile", al_load_sample("guile.wav"))); + themes.insert(pair("Mine", al_load_sample("customtheme.wav"))); + font = al_create_builtin_font(); } @@ -50,7 +53,7 @@ void Game::reset() { //Run the game state machine void Game::run() { //Load screens - GameScreen game_screen(sprites, samples); + GameScreen game_screen(sprites, samples, themes); StartScreen start_screen(sprites); ResultScreen result_screen(sprites, 0, 0, Easy); int difficulty = 1; //Difficulty to run @@ -112,4 +115,8 @@ void Game::run() { for (it2 = samples.begin(); it2 != samples.end(); it2++) { al_destroy_sample(it2->second); } + map::iterator it3; + for (it3 = themes.begin(); it3 != themes.end(); it3++) { + al_destroy_sample(it3->second); + } } \ No newline at end of file diff --git a/TrustFall/TrustFall/game.h b/TrustFall/TrustFall/game.h index 1354ce1..c97ddf7 100644 --- a/TrustFall/TrustFall/game.h +++ b/TrustFall/TrustFall/game.h @@ -4,33 +4,34 @@ #include #include #include -#include - -#include -#include -#include - -#include "enums.h" - -//Game state machine, contains data global to game -class Game { -public: - //Allegro elements - ALLEGRO_FONT* font; - - //Game elements - State state; - - int score; - - std::map sprites; - std::map samples; - - Game(); - - void init(); - void run(); - -private: - void reset(); +#include + +#include +#include +#include + +#include "enums.h" + +//Game state machine, contains data global to game +class Game { +public: + //Allegro elements + ALLEGRO_FONT* font; + + //Game elements + State state; + + int score; + + std::map sprites; + std::map samples; + std::map themes; + + Game(); + + void init(); + void run(); + +private: + void reset(); }; \ No newline at end of file diff --git a/TrustFall/TrustFall/game_screen.cpp b/TrustFall/TrustFall/game_screen.cpp index 3e39b6e..8334aec 100644 --- a/TrustFall/TrustFall/game_screen.cpp +++ b/TrustFall/TrustFall/game_screen.cpp @@ -18,9 +18,10 @@ using std::ostringstream; using std::map; using std::pair; -GameScreen::GameScreen(std::map _sprites, std::map _samples) { +GameScreen::GameScreen(std::map _sprites, std::map _samples, std::map _themes) { sprites = _sprites; samples = _samples; + themes = _themes; srand(time(NULL)); //Seed random number generator with current time so sequence is unique each run } @@ -75,14 +76,21 @@ void GameScreen::run(ALLEGRO_FONT* font) { //Create map of sample instances. This is more memory efficient than play samples over and over again individually, //and allows the anti-overlap functionality implemented above. map instances; + map theme_instances; map::iterator it; for (it = samples.begin(); it != samples.end(); it++) { instances.insert(pair(it->first, al_create_sample_instance(it->second))); al_attach_sample_instance_to_mixer(instances[it->first], al_get_default_mixer()); } + for (it = themes.begin(); it != themes.end(); it++) { + theme_instances.insert(pair(it->first, al_create_sample_instance(it->second))); + al_attach_sample_instance_to_mixer(theme_instances[it->first], al_get_default_mixer()); + } - al_set_sample_instance_playmode(instances["Theme"], ALLEGRO_PLAYMODE_LOOP); - play(instances["Theme"]); + map::iterator theme_it = theme_instances.begin(); + std::advance(theme_it, rand() % (theme_instances.size())); + al_set_sample_instance_playmode(theme_it->second, ALLEGRO_PLAYMODE_LOOP); + play(theme_it->second); int ticks = 0; //Counts the number of ticks, this is used to determine when to move the lines bool exit_screen = false; @@ -106,6 +114,7 @@ void GameScreen::run(ALLEGRO_FONT* font) { for (in_it = instances.begin(); in_it != instances.end(); in_it++) { al_stop_sample_instance(in_it->second); } + al_stop_sample_instance(theme_it->second); al_play_sample_instance(instances["Fall"]); exit_screen = true; al_clear_to_color(al_map_rgb(0, 0, 0)); @@ -157,10 +166,10 @@ void GameScreen::run(ALLEGRO_FONT* font) { //Toggle music if (ctrl) { if (music) { - al_stop_sample_instance(instances["Theme"]); + al_stop_sample_instance(theme_it->second); } else { - al_play_sample_instance(instances["Theme"]); + al_play_sample_instance(theme_it->second); } music = !music; } diff --git a/TrustFall/TrustFall/game_screen.h b/TrustFall/TrustFall/game_screen.h index c407043..2e928af 100644 --- a/TrustFall/TrustFall/game_screen.h +++ b/TrustFall/TrustFall/game_screen.h @@ -7,6 +7,7 @@ class GameScreen : public Screen { public: std::map sprites; std::map samples; + std::map themes; std::vector lines; unsigned int selected; int max_catchers; @@ -15,7 +16,7 @@ public: int difficulty; bool music; - GameScreen(std::map _sprites, std::map _samples); + GameScreen(std::map _sprites, std::map _samples, std::map _themes); void reset(int _lines, int _max_catchers, int _difficulty); void run(ALLEGRO_FONT* font); diff --git a/TrustFall/TrustFall/guile.wav b/TrustFall/TrustFall/guile.wav new file mode 100644 index 0000000..dbf0d84 Binary files /dev/null and b/TrustFall/TrustFall/guile.wav differ diff --git a/TrustFall/TrustFall/packages.config b/TrustFall/TrustFall/packages.config index 0c6bbd7..986b1a9 100644 --- a/TrustFall/TrustFall/packages.config +++ b/TrustFall/TrustFall/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/TrustFall/TrustFall/start_screen.cpp b/TrustFall/TrustFall/start_screen.cpp index ac1b5cf..18e4ef1 100644 --- a/TrustFall/TrustFall/start_screen.cpp +++ b/TrustFall/TrustFall/start_screen.cpp @@ -85,12 +85,12 @@ 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, "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"); - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 30, ALLEGRO_ALIGN_CENTER, "conveyor belts to make sure no other employees fall off."); - al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 40, ALLEGRO_ALIGN_CENTER, "Try to catch enough to help the team bond!"); - - //Keys and their associated functions + 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"); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 30, ALLEGRO_ALIGN_CENTER, "conveyor belts to make sure no other employees fall off."); + al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 40, ALLEGRO_ALIGN_CENTER, "Try to catch enough to help the team bond!"); + + //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");