#include "raylib.h" #include "string.h" #include #include #include "sprite.h" #include "Input/inputHandler.h" #include "raymath.h" #include "List/list.h" #include "IsometricMap/isometricMap.h" #include "game.h" #include "DepthSorting/bucket.h" #include "Ui/screenIDs.h" #include "Ui/button.h" #include "Ui/uiContainer.h" #include "Ui/debug.h" int main(){ InitWindow(1280, 720, "basic window"); Game *game = GameInit(); // TODO: Screen structs, die zum Beispiel die UiContainer enthalten? UiContainer *pauseScreenUiContainer = UiContainerInitPauseUiContainer(); UiContainer *mainMenuScreenUiContainer = UiContainerInitMainMenuUiContainer(); // Hides the operating systems own cursor HideCursor(); SetTargetFPS(60); while(!WindowShouldClose()){ // Moving cursor Sprite to Mouse Pos game->cursorSprite->x = GetMousePosition().x; game->cursorSprite->y = GetMousePosition().y; BeginDrawing(); // Drawing ist grundsätzlich immer aktiviert ClearBackground(RAYWHITE); // Screen wird in jedem Frame gecleared switch(game->screen){ // Screenspecific Code case SCREEN_EXIT: printf("EXIT \n"); return 0; case SCREEN_MAINMENU: // MainMenu hat aktuell nur paar Buttons UiContainerUpdateUiContainer(mainMenuScreenUiContainer, game); UiContainerDrawUiContainer(mainMenuScreenUiContainer); break; case SCREEN_OPTIONS: printf("OPTIONS \n"); return 0; case SCREEN_GAME: // Updating Sprites ListActAllSprites(game); // Drawing IsometricMap BeginMode2D(*(game->camera)); // Sorgt dafür, dass die Kameraposition beachtet wird IsometricMapDraw(game); EndMode2D(); // User Input Handling mouseInput(game); keyboardInput(game->inputHandler, game->camera); if(IsKeyPressed(KEY_P)){ game->screen = SCREEN_PAUSE; } break; case SCREEN_PAUSE: // Still drawing isometric map, which is not updated atm BeginMode2D(*(game->camera)); // Sorgt dafür, dass die Kameraposition beachtet wird IsometricMapDraw(game); EndMode2D(); // darkened background + "Paused" Text DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), (Color){0, 0, 0, 150}); int textWidthHalf = MeasureText("Paused", 28) / 2; DrawText("Paused", GetScreenWidth()/2 - textWidthHalf, GetScreenHeight()/4 - 14, 28, WHITE); // Controls lol DrawText("I: Zoom in", 5, GetScreenHeight()/2, 16, WHITE); DrawText("K: Zoom out", 5, GetScreenHeight()/2 + 16, 16, WHITE); DrawText("P: Pause", 5, GetScreenHeight()/2 + 32, 16, WHITE); DrawText("WASD: Move Camera", 5, GetScreenHeight()/2 + 48, 16, WHITE); DrawText("ESC: Exit Game", 5, GetScreenHeight()/2 + 64, 16, WHITE); // Button / UI stuff UiContainerUpdateUiContainer(pauseScreenUiContainer, game); UiContainerDrawUiContainer(pauseScreenUiContainer); // Debug Menu DebugDraw(game, pauseScreenUiContainer); if(IsKeyPressed(KEY_P)){ game->screen = SCREEN_GAME; } break; default: printf("\n\n\n\n\n\n Wir haben ein problematisches Problem! Die Screen-ID [%d] ist nicht definiert. Hmmpf... früher bescheid wisse!\n\n\n\n\n\n", game->screen); return 1; break; } // Dinge die grundsätzlich immer gedrawed werden sollen // Debug Menu, FPS anzeige, Cursor DebugDraw(game, pauseScreenUiContainer); DrawFPS(GetScreenWidth() - 95, 10); DrawSpriteToScreen(game->cursorSprite); EndDrawing(); } CloseWindow(); return 0; }