diff --git a/main.c b/main.c index 107b1c3..49e0c10 100644 --- a/main.c +++ b/main.c @@ -47,12 +47,12 @@ SDL_Window * window; SDL_Renderer * renderer; SDL_Event event; bool running = true, fullscreen = false; -GameState gameState = Game; +GameState gameState = MainMenu; Scenery scenery; int main(int argc, char * args[]){ - printf("Spielbereiche\n\t- 1: Hauptmen"ue "\n\t- 2: Spiel\n\t- 3: Level Select\n\t- 4: Settings\n\t- 5: Highscores\n"); - GAME_ChangeState(readIntFromIO("W"ae "hle einen Spielbereich aus, den du testen m"oe "chtest:", "Fehlerhafte Eingabe!\n", "%d ist kein g"ue "ltiger Spielbereich!\n", 1, 5)); + //printf("Spielbereiche\n\t- 1: Hauptmen"ue "\n\t- 2: Spiel\n\t- 3: Level Select\n\t- 4: Settings\n\t- 5: Highscores\n"); + //GAME_ChangeState(readIntFromIO("W"ae "hle einen Spielbereich aus, den du testen m"oe "chtest:", "Fehlerhafte Eingabe!\n", "%d ist kein g"ue "ltiger Spielbereich!\n", 1, 5)); INITIALIZE(); while (running) { // Gameloop HandleSDLEvents(); @@ -64,6 +64,7 @@ int main(int argc, char * args[]){ break; case MainMenu: // Startmenu_Update(keystate); + Startmenu_Draw(renderer); break; case Highscores: @@ -111,6 +112,7 @@ void HandleSDLEvents(){ break; case SDL_MOUSEBUTTONDOWN: mousePress(event.button); + button_clicked(event.button); break; case SDL_WINDOWEVENT: windowChanged(event.window); diff --git a/startmenu.c b/startmenu.c index 13afc14..7eb677e 100644 --- a/startmenu.c +++ b/startmenu.c @@ -2,6 +2,8 @@ #include #include #include +#include "gamestate.h" + SDL_Texture* TITLE_Texture; SDL_Texture* PLAYBUTTON_Texture; @@ -56,18 +58,18 @@ void Startmenu_Draw (SDL_Renderer* renderer) { SDL_RenderCopy(renderer, QUITBUTTON_Texture, NULL, &QUITBUTTON_Rect); } -int button_clicked(SDL_MouseButtonEvent b) { - if(clickInRect(b, PLAYBUTTON_Rect) == 1) { +void button_clicked(SDL_MouseButtonEvent b) { + if(clickInRect(b, &PLAYBUTTON_Rect) == 1) { GAME_ChangeState(Game); - } else if (clickInRect(b, SKINSBUTTON_Rect) == 1) { + } else if (clickInRect(b, &SKINSBUTTON_Rect) == 1) { GAME_ChangeState(SkinSelect); - } else if (clickInRect(b, LEVELBUTTON_Rect) == 1) { + } else if (clickInRect(b, &LEVELBUTTON_Rect) == 1) { GAME_ChangeState(LevelSelect); - } else if (clickInRect(b, SETTINGSBUTTON_Rect) == 1) { + } else if (clickInRect(b, &SETTINGSBUTTON_Rect) == 1) { GAME_ChangeState(Settings); - } else if (clickInRect(b, HIGHSCORESBUTTON_Rect) == 1) { + } else if (clickInRect(b, &HIGHSCORESBUTTON_Rect) == 1) { GAME_ChangeState(Highscores); - } else if (clickInRect(b, QUITBUTTON_Rect) == 1) { + } else if (clickInRect(b, &QUITBUTTON_Rect) == 1) { GAME_Escape(); } } diff --git a/startmenu.h b/startmenu.h index ee4d6cd..82fff3d 100644 --- a/startmenu.h +++ b/startmenu.h @@ -12,4 +12,8 @@ void Load_Textures (SDL_Renderer* renderer); void Startmenu_Draw (SDL_Renderer* renderer); +void button_clicked(SDL_MouseButtonEvent b); + +int clickInRect(SDL_MouseButtonEvent b, SDL_Rect* area_rect); + #endif