currently i am creating a main menu for a game in which I want a background music played and a different one when the game actual starts, the game starts by pressing the "w" key, but the music doesn't changes, any help will be much appreciated.
#include "globals.h"
enum State { main_menu, fighting };
State state;
#include "Fighters.h"
Fighters game;
#include "music.h"
Music gb_music;
int main(int argc, char**argv){
game.initialize();
state = main_menu;
while (is_running) {
ticks_for_caping_fps = SDL_GetTicks();
while (SDL_PollEvent(&main_event)) {
if (main_event.type == SDL_QUIT) {
is_running = false;
break;
}
if (main_event.type == SDL_KEYDOWN) {
switch (main_event.key.keysym.sym) {
case SDLK_w:
state = fighting;
break;
case SDLK_s:
state = main_menu;
break;
}
}
//it behaves improperly here, but if i move it out of the que it doesnt even work unless i keep dragging the window arround
gb_music.load_background_music();
}
SDL_SetRenderDrawColor(grender, 255, 255, 255, 255);
SDL_RenderClear(grender);
game.load_main_menu(main_event);
SDL_RenderPresent(grender);
capfps(ticks_for_caping_fps);
}
return 0;
}