diff --git a/games b/games new file mode 160000 index 0000000..6c1513a --- /dev/null +++ b/games @@ -0,0 +1 @@ +Subproject commit 6c1513a50823909c2f5fc39adff1d701cba6b2ac diff --git a/include/ArcadeMachine.h b/include/ArcadeMachine.h index 24fc101..0548ea6 100644 --- a/include/ArcadeMachine.h +++ b/include/ArcadeMachine.h @@ -19,6 +19,7 @@ #include #include #include +#include "AudioSetting.h" // Define number of rows and columns in grid #define ROWS 7 @@ -79,6 +80,9 @@ class ArcadeMachine /// Turn menu music on/off bool m_playMusic = true; + ///Music controller + Audio audio; + /// Menu button node ButtonNode *m_menuButtonNode = nullptr; diff --git a/include/Audio.h b/include/Audio.h index e5e1677..f169582 100644 --- a/include/Audio.h +++ b/include/Audio.h @@ -6,67 +6,42 @@ class Audio { private: vector m_music; - int songId; + int songId = 4; + float volume = 5; public: Audio() { - getAllMusic(); } void setSongId(int id) { - this->songId = id; - } - - void playMusic(float volume) - { - play_music(m_music[0]); - set_music_volume(volume); - setSongId(0); - } - - void playMusic(std::string song, float volume) - { - play_music(song); - set_music_volume(volume); - music thisSong = music_named(song); - - for (int i = 0; i < this->m_music.size(); i++) - { - if (thisSong == this->m_music[i]) - { - write_line("same song"); - setSongId(i); - } + if(this->songId != id){ + this->songId = id; + stop_music(); + playMusic(id); } } - - void playMusic(int _currentMusic, float volume) - { - play_music(std::to_string(_currentMusic)); - set_music_volume(volume); - } - - void playNextSong() + void playMusic(int _currentMusic) { - if (this->songId != (this->m_music.size() - 1)) - play_music(this->m_music[this->songId + 1]); - else - play_music(this->m_music[0]); + if(!music_playing()){ + play_music(std::to_string(_currentMusic)); + set_music_volume(this->volume/10); + } + } + void set_volume_for_machine(){ + set_music_volume(this->volume/10); } - void setVolume(float volume) { - set_music_volume(volume); + this->volume = volume; } - - void getAllMusic() - { - m_music.push_back(music_named("music_mainmenu")); - m_music.push_back(music_named("1")); - m_music.push_back(music_named("2")); - m_music.push_back(music_named("3")); + float getVolume(){ + return this->volume; + } + int getCurrentMusic(){ + return songId; } + }; #endif diff --git a/include/AudioSetting.h b/include/AudioSetting.h new file mode 100644 index 0000000..f1ff1a2 --- /dev/null +++ b/include/AudioSetting.h @@ -0,0 +1,43 @@ +#ifndef ARCADE_MACHINE_AUDIO_SETTING_H +#define ARCADE_MACHINE_AUDIO_SETTING_H + +#include "splashkit.h" +#include "GridLayout.h" +#include "Button.h" +#include "Selector.h" +class AudioSetting +{ +private: + int _selector = 1; + float m_volume = 40; + bool m_isOptionOpen = true; + + GridLayout m_grid; + std::vector m_optionsBtns; + // ButtonNode *m_optionsButtonNode = nullptr; + // Selector m_selectorOptionsMenu; + // point_2d m_mouse; + // std::string m_action; + // AboutScreen m_aboutScreen; + +public: + AudioSetting(); + + void changeVolume(); + void changeMucis(); + void drawHub(){ + draw_text("CHANGE SOUND", color_white(), 3131312 + 100, 200); + }; + float getVolume(); + int getCurrentMusic(); + void setCurrentMusic(); + void volumeControl(); + void changeDisplay(); + void playAboutScreen(); + bool isChangeMusic(); + bool isChangeVoLume(); + void changeSelector(); + void updateOption(); + void drawIntinialHub(); +}; +#endif \ No newline at end of file diff --git a/include/Option.h b/include/Option.h index dcd4824..b00ce90 100644 --- a/include/Option.h +++ b/include/Option.h @@ -10,6 +10,7 @@ #include "Selector.h" #include "OptionsScreenButton.h" #include "Audio.h" +// #include "AudioSetting.h" // Options class class Option @@ -22,7 +23,7 @@ class Option int m_insideSeletor = 1; float m_volume = 40; bool m_isOptionOpen = true; - + // AudioSetting m_audio_setting; GridLayout m_grid; Audio m_audio; std::vector m_optionsBtns; @@ -34,16 +35,39 @@ class Option public: Option(); - void createOptionsButtons(); void drawOptionsMenu(); - bool checkAction(); - void soundMenu(); + bool checkAction(Audio &audio); + void soundMenu(Audio &audio); + float getVolume(); + void setCurrentMusic(Audio &audio) + { + if(key_typed(LEFT_KEY)) + { + if(audio.getCurrentMusic()>1) + audio.setSongId(audio.getCurrentMusic()-1); + else + audio.setSongId(4); - float getVolume(); - int getCurrentMusic(); - void setCurrentMusic(); + } + if(key_typed(RIGHT_KEY)){ + if(audio.getCurrentMusic()<4) + audio.setSongId(audio.getCurrentMusic()+1); + else + audio.setSongId(1);} + } + void changeVolume(Audio &audio){ + if(key_typed(K_KEY)){ + audio.setVolume(audio.getVolume()-1); + set_music_volume(audio.getVolume()/10); + } + if(key_typed(L_KEY)){ + audio.setVolume(audio.getVolume()+1); + set_music_volume(audio.getVolume()/10); + } + + } void volumeControl(); void changeDisplay(); void playAboutScreen(); diff --git a/resources/bundles/resources.txt b/resources/bundles/resources.txt index a632c5d..5f3335b 100644 --- a/resources/bundles/resources.txt +++ b/resources/bundles/resources.txt @@ -37,6 +37,12 @@ BITMAP,changeSound,buttons/Red/MusicOn.png BITMAP,sound_notSelected,buttons/Yellow/MusicOn.png BITMAP,backMenu_notSelected,buttons/Yellow/Home.png BITMAP,backMenu,buttons/Red/Home.png +BITMAP,volumeDown,volumeDown.png +BITMAP,volumeUp,volumeUp.png +BITMAP,sound_image,sound_image.jpg +BITMAP,sound_image2,sound_image2.jpg +BITMAP,sound_image3,sound_image3.jpg +BITMAP,sound_image4,sound_image4.png // Cursors BITMAP,cursor,splashkit_cursor.png @@ -61,7 +67,7 @@ SOUND,intro_coin,coin.wav SOUND,intro_start,completed.wav // Music -MUSIC,music_mainmenu,main_menu.mp3 +MUSIC,4,main_menu.mp3 MUSIC, 1, 1.mp3 MUSIC, 2, 2.mp3 MUSIC, 3, 3.mp3 diff --git a/resources/images/sound_image.jpg b/resources/images/sound_image.jpg new file mode 100644 index 0000000..591717e Binary files /dev/null and b/resources/images/sound_image.jpg differ diff --git a/resources/images/sound_image2.jpg b/resources/images/sound_image2.jpg new file mode 100644 index 0000000..798467f Binary files /dev/null and b/resources/images/sound_image2.jpg differ diff --git a/resources/images/sound_image3.jpg b/resources/images/sound_image3.jpg new file mode 100644 index 0000000..4f4f33a Binary files /dev/null and b/resources/images/sound_image3.jpg differ diff --git a/resources/images/sound_image4.png b/resources/images/sound_image4.png new file mode 100644 index 0000000..82b8472 Binary files /dev/null and b/resources/images/sound_image4.png differ diff --git a/resources/images/volumeDown.png b/resources/images/volumeDown.png new file mode 100644 index 0000000..9e551f4 Binary files /dev/null and b/resources/images/volumeDown.png differ diff --git a/resources/images/volumeUp.png b/resources/images/volumeUp.png new file mode 100644 index 0000000..62a7d7c Binary files /dev/null and b/resources/images/volumeUp.png differ diff --git a/src/AboutScreen.cpp b/src/AboutScreen.cpp index 37a339c..24b1684 100644 --- a/src/AboutScreen.cpp +++ b/src/AboutScreen.cpp @@ -83,8 +83,8 @@ AboutScreen::AboutScreen() { } void AboutScreen::onExit() { - if (music_playing()) - stop_music(); + // if (music_playing()) + // stop_music(); } void AboutScreen::readInput() { @@ -98,10 +98,10 @@ void AboutScreen::tick() { this->tickContributor(); // Every 1/4 second. - if (this->m_ticker % 15 == 0) { - if (! music_playing()) - play_music("music_about"); - } + // if (this->m_ticker % 15 == 0) { + // if (! music_playing()) + // play_music("music_about"); + // } this->m_ticker++; } @@ -219,8 +219,8 @@ void AboutScreen::loop() { void AboutScreen::main() { // Clear music and start the about screen music. - stop_music(); - play_music("music_about"); + // stop_music(); + // play_music("music_about"); this->loop(); diff --git a/src/ArcadeMachine.cpp b/src/ArcadeMachine.cpp index 3ccb8df..aac5e76 100644 --- a/src/ArcadeMachine.cpp +++ b/src/ArcadeMachine.cpp @@ -40,6 +40,7 @@ ArcadeMachine::ArcadeMachine() Splashscreen introArcadeMachineTeam("intro_arcade_team"); Splashscreen introSplashkit("intro_splashkit"); + Audio audio; // Set objects to private properties this->m_helper = helper; @@ -48,6 +49,7 @@ ArcadeMachine::ArcadeMachine() this->m_introThothTech = introThothTech; this->m_introArcadeTeam = introArcadeMachineTeam; this->m_introSplashkit = introSplashkit; + this->audio = audio; } ArcadeMachine::~ArcadeMachine() @@ -68,6 +70,11 @@ void ArcadeMachine::mainMenu() { while (!quit_requested()) { + this->audio.playMusic(this->audio.getCurrentMusic()); + audio.set_volume_for_machine(); + if(key_typed(P_KEY)){ + write_line(audio.getVolume()); + } process_events(); clear_screen(); drawMainMenu(); @@ -79,6 +86,7 @@ void ArcadeMachine::mainMenu() /** Starts the Games Menu */ + void ArcadeMachine::gamesMenu() { // Instantiate new menu @@ -107,7 +115,6 @@ void ArcadeMachine::gamesMenu() refresh_screen(60); } } - /** Starts the Options Menu */ @@ -121,17 +128,9 @@ void ArcadeMachine::optionsMenu() { process_events(); clear_screen(); - //options.updateOption(); options.drawOptionsMenu(); - - this->m_exitOptions = options.checkAction(); - - if(!has_background_music) - { - //audio->playMusic(options.getCurrentMusic(), options.getVolume()); - has_background_music=false; - } + this->m_exitOptions = options.checkAction(this->audio); if(options.isChangeMusic()) { @@ -249,7 +248,8 @@ void ArcadeMachine::prepareMainMenu() this->m_grid.updateCell(m_menuButtonNode->getNext()->button, 3, 10); // Play main menu music - if (this->m_playMusic) play_music("music_mainmenu"); + // if (this->m_playMusic) play_music("music_mainmenu"); + } /// Plays the Thoth Tech splashscreen animation diff --git a/src/Audio.cpp b/src/Audio.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Option.cpp b/src/Option.cpp index 9c284d3..f694d22 100644 --- a/src/Option.cpp +++ b/src/Option.cpp @@ -1,7 +1,145 @@ #include "Option.h" Option::Option() {} - +// class Audio{ +// private: +// int _selector; +// bool has_background_music = false; +// public: +// Audio(){} + +// void playMusic(int _currentMusic,float volume) +// { +// play_music(to_string(_currentMusic)); +// set_music_volume(volume); +// } + +// void setVolume(float volume) +// { +// set_music_volume(volume); +// } +// void VolumeControl() +// { +// if(_selector==2&&_isSelected&&key_typed(RIGHT_KEY)&&_volume<100&&_insideSeletor==1) +// { +// _volume=_volume+20; +// } +// if(_selector==2&&_isSelected&&key_typed(LEFT_KEY)&&_volume>0&&_insideSeletor==1) +// { +// _volume=_volume-20; +// } +// } + +// void setCurrentMusic() +// { +// if(_selector==2&&_isSelected&&_volume<100&&_insideSeletor==2) +// { +// if(key_typed(LEFT_KEY)&&_currentMusic>1) +// { +// _currentMusic=_currentMusic-1; +// } +// if(key_typed(RIGHT_KEY)&&_currentMusic<3) +// { +// _currentMusic=_currentMusic+1; +// } +// } +// } + +// int getCurrentMusic() +// { +// return _currentMusic; +// } +// void play_music_in_loop(){ +// if(!has_background_music) +// { +// audio->playMusic(options.getCurrentMusic(), options.getVolume()); +// has_background_music=true; +// } +// } +// void drawIntinialHub() +// { +// const string settingImage = path_to_resource("back_ground", IMAGE_RESOURCE); +// bitmap back =load_bitmap("back_ground",settingImage); +// _grid->SetBackground(back); +// _grid->UpdateCell(homeReturn,0,0); +// _grid->UpdateCell(soundSetting,1,0); +// // _grid->UpdateCell(menuSetting,2,0); +// _grid->UpdateCell(gameReturn,3,0); + +// draw_bitmap("back_ground", bitmap_width("backCurrentGame"), 0); + +// if(_selector==1) +// { +// // draw_bitmap("backCurrentGame", 0, 0); +// // draw_bitmap("sound_notSelected", 0, bitmap_height("backCurrentGame")); +// // // draw_bitmap(); +// // draw_bitmap("backMenu_notSelected", 0, 3*bitmap_height("backCurrentGame")); +// _grid->DrawGrid(); +// draw_text("RESET DEFAULT", color_red(), 400, 100); +// draw_text("yes", color_red(), 300, 300); +// draw_text("no", color_red(), 700, 300); + +// } + +// if(_selector==2) +// { +// // draw_bitmap("changeSound",0,bitmap_height("backCurrentGame")); +// // draw_bitmap("backGame_notSelected",0,0); +// // // draw_bitmap(); +// // draw_bitmap("backMenu_notSelected",0,3*bitmap_height("backCurrentGame")); +// _grid->DrawGrid(); + +// fill_rectangle(color_red(),bitmap_width("backCurrentGame")+200,200,screen_width()-bitmap_width("backCurrentGame")-400,50); +// double a=screen_width()-bitmap_width("backCurrentGame")-400; +// double b=a/100*_volume; +// fill_rectangle(color_yellow(),bitmap_width("backCurrentGame")+200,200,b,50); +// draw_text(to_string(screen_width()-bitmap_width("backCurrentGame")),color_red(),300,300); + +// if (_insideSeletor==1) +// { +// draw_text("CHANGE SOUND",color_white(),bitmap_width("backCurrentGame")+100,200); +// } + +// if(_insideSeletor==2) +// { +// draw_text("CHANGE MUSIC",color_white(),bitmap_width("backCurrentGame")+100,500); +// draw_text(to_string(_currentMusic),color_white(),bitmap_width("backCurrentGame")+250,500); +// } +// } + +// if(_selector==3) +// { +// double x=screen_width(); +// double y=screen_height(); +// double a=bitmap_width("backCurrentGame"); +// double rec_width=(x-a-450)/2; +// double rec_height=(y-450)/2; +// double first_column_x=150+a; +// double secong_column_x=a+300+rec_width; +// double first_row_y=150; +// double second_row_y=300+rec_height; +// fill_rectangle(color_white(),first_column_x,first_row_y,rec_width,rec_height); +// fill_rectangle(color_white(),secong_column_x,first_row_y,rec_width,rec_height); +// fill_rectangle(color_white(),first_column_x,second_row_y,rec_width,rec_height); +// fill_rectangle(color_white(),secong_column_x,second_row_y,rec_width,rec_height); +// if(_displayStyle==1){fill_rectangle(color_red(),first_column_x,first_row_y,rec_width,rec_height);} +// if(_displayStyle==2){fill_rectangle(color_red(),secong_column_x,first_row_y,rec_width,rec_height);} +// if(_displayStyle==3){fill_rectangle(color_red(),first_column_x,second_row_y,rec_width,rec_height);} +// if(_displayStyle==4){fill_rectangle(color_red(),secong_column_x,second_row_y,rec_width,rec_height);} +// } + +// if(_selector==4) +// { +// // draw_bitmap("backMenu",0,3*bitmap_height("backCurrentGame")); +// // draw_bitmap("sound_notSelected",0,bitmap_height("backCurrentGame")); +// // // draw_bitmap(); +// // draw_bitmap("backGame_notSelected",0,0); +// _grid->DrawGrid(); +// } + +// } +// }; + void Option::createOptionsButtons() { // Initialise grid @@ -89,13 +227,13 @@ void Option::drawOptionsMenu() this->m_action = this->m_selectorOptionsMenu.checkForSelection(this->m_optionsButtonNode); } -bool Option::checkAction() +bool Option::checkAction(Audio &audio) { if (this->m_action == "home") return true; if (this->m_action == "sound") - this->soundMenu(); + this->soundMenu(audio); if (this->m_action == "stats") this->playAboutScreen(); @@ -103,10 +241,101 @@ bool Option::checkAction() return false; } -void Option::soundMenu() +void Option::soundMenu(Audio &audio) { - write_line("into sound options mini menu"); - + // AudioSetting audioSetting; + // audioSetting.drawHub(); + vector images; + images.push_back(create_sprite(bitmap_named("sound_image"))); + images.push_back(create_sprite(bitmap_named("sound_image2"))); + images.push_back(create_sprite(bitmap_named("sound_image3"))); + images.push_back(create_sprite(bitmap_named("sound_image4"))); + for(int i=0;i<4;i++){ + sprite_set_x(images[i],screen_width()/2-300+20+i*560); + sprite_set_y(images[i],220); + } + int current = audio.getCurrentMusic(); + if(current == 1){ + sprite_set_x(images[0],screen_width()/2-300+20); + sprite_set_y(images[0],220); + sprite_set_x(images[3],screen_width()/2-300+20-560); + sprite_set_y(images[3],220); + sprite_set_x(images[1],screen_width()/2-300+20+560); + sprite_set_y(images[1],220); + sprite_set_x(images[2],screen_width()/2-300+20+2*560); + sprite_set_y(images[2],220); + }else{ + for(int i = current-1;i<=4;i++){ + sprite_set_x(images[i-1],screen_width()/2-300+20+(i-current)*560); + sprite_set_y(images[i-1],220); + } + for(int i =1;iscreen_width()/2-300+20-560){ + for(int i=0;i<4;i++){ + sprite_set_dx(images[i],-1); + } + } + else if(moveLeft == true && sprite_x(images[current-1])setCurrentMusic(audio); + this->changeVolume(audio); + // fill_rectangle(color_blue(), screen_width()/2-300, 200, 600, 300); + fill_rectangle(color_white(), 0, 200+20, screen_width()/2-560/2, 300-40); + fill_rectangle(color_white(), screen_width()/2+560/2, 200+20, screen_width()/2-560/2, 300-40); + + draw_bitmap("volumeDown",200, 700); + draw_text(std::to_string(audio.getCurrentMusic()), COLOR_BLACK, "Times New Roman", 60, 300, 200); + draw_bitmap("volumeDown",200, 700); + draw_bitmap("volumeUp",screen_width()-200-bitmap_width("volumeUp"),700); + fill_rectangle(color_red(), screen_width()/2-500, 700, 1000, bitmap_height("volumeUp")); + fill_rectangle(color_blue(), screen_width()/2-500, 700, 1000*music_volume(), bitmap_height("volumeUp")); + refresh_screen(); + } + //draw_text("Volume", COLOR_BLACK, "font_title", 60, 300, 200); } @@ -124,21 +353,10 @@ void Option::volumeControl() m_volume -= 20; } -void Option::setCurrentMusic() -{ - if(_selector == 2 && m_isSelected && m_volume < 100 && m_insideSeletor == 2) - { - if(key_typed(LEFT_KEY) && m_currentMusic > 1) - m_currentMusic = m_currentMusic-1; - if(key_typed(RIGHT_KEY) && m_currentMusic < 3) - m_currentMusic = m_currentMusic+1; - } -} -int Option::getCurrentMusic() -{ - return m_currentMusic; -} + + + void Option::changeDisplay() { @@ -238,7 +456,7 @@ void Option::updateOption() { changeSelector(); changeDisplay(); - setCurrentMusic(); + // setCurrentMusic(); volumeControl(); drawIntinialHub(); } diff --git a/stats/contributors.txt b/stats/contributors.txt index aaf340a..04e3418 100644 --- a/stats/contributors.txt +++ b/stats/contributors.txt @@ -1,5 +1,5 @@ -131 Anthony George -98 Richard Denton +132 Anthony George +120 Richard Denton 62 Riley Dellios 60 lachfoy 30 Sarah Gosling diff --git a/stats/git.txt b/stats/git.txt index df9eb3f..75ffc52 100644 --- a/stats/git.txt +++ b/stats/git.txt @@ -1,3 +1,3 @@ -Commits: 507 -Branches: 35 +Commits: 524 +Branches: 10 Contributors: 9 \ No newline at end of file diff --git a/stats/lines-of-code.txt b/stats/lines-of-code.txt index 2a2d7fa..53f1aaa 100644 --- a/stats/lines-of-code.txt +++ b/stats/lines-of-code.txt @@ -1,2 +1,2 @@ -C++ (code): 2822 -C++ (header): 2097 \ No newline at end of file +C++ (code): 2963 +C++ (header): 2134 \ No newline at end of file