You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.6 KiB
119 lines
3.6 KiB
#include "raylib.h"
|
|
#include "string.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#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 "DepthSorting/mergeSort.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();
|
|
ClearBackground(RAYWHITE);
|
|
switch(game->screen){
|
|
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()/2 - 14, 28, 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;
|
|
|
|
}
|
|
|