Screens hinzugefügt, Selectable / Button erstellen ist jetzt einfacher, Selectable und Button Texturen sind jetzt auch im TextureAtlas
parent
2a8bbeefd2
commit
f9a24a52c2
@ -0,0 +1,102 @@
|
|||||||
|
#include "screen.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "../definitions.h"
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "../Sprite/sprite.h"
|
||||||
|
#include "../Input/inputHandler.h"
|
||||||
|
#include "../Entity/entity.h"
|
||||||
|
#include "../IsometricMap/isometricMap.h"
|
||||||
|
#include "../game.h"
|
||||||
|
#include "../Ui/uiContainer.h"
|
||||||
|
|
||||||
|
void ScreenRenderEmptyScreen(Game *game){
|
||||||
|
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->currentScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenRenderExitScreen(Game *game){
|
||||||
|
printf("EXIT \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenRenderGameScreen(Game *game){
|
||||||
|
game->screens[game->currentScreen]->frameCounter += GetFrameTime();
|
||||||
|
if(game->screens[game->currentScreen]->frameCounter >= ACT_TIME){
|
||||||
|
EntityListActAllEntities(game);
|
||||||
|
game->screens[game->currentScreen]->frameCounter = 0;
|
||||||
|
}
|
||||||
|
// Drawing IsometricMap
|
||||||
|
BeginMode2D(*(game->camera)); // Sorgt dafür, dass die Kameraposition beachtet wird
|
||||||
|
IsometricMapDraw(game);
|
||||||
|
|
||||||
|
SpriteListDrawAllSprites(game->sprites, game->map, game->camera);
|
||||||
|
EndMode2D();
|
||||||
|
|
||||||
|
// User Input Handling
|
||||||
|
mouseInput(game);
|
||||||
|
keyboardInput(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenRenderMainMenuScreen(Game *game){
|
||||||
|
// hmmmmm
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenRenderPauseScreen(Game *game){
|
||||||
|
int halfScreenHeight = GetScreenHeight()/2;
|
||||||
|
|
||||||
|
// Still drawing isometric map, which is not updated atm
|
||||||
|
BeginMode2D(*(game->camera)); // Sorgt dafür, dass die Kameraposition beachtet wird
|
||||||
|
IsometricMapDraw(game);
|
||||||
|
SpriteListDrawAllSprites(game->sprites, game->map, game->camera);
|
||||||
|
EndMode2D();
|
||||||
|
UiContainerDrawUiContainer(game->screens[game->currentScreen]->uiContainer);
|
||||||
|
// 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, (halfScreenHeight/2) - 14, 28, WHITE);
|
||||||
|
|
||||||
|
// Controls lol
|
||||||
|
DrawText("I: Zoom in", 5, halfScreenHeight, 16, WHITE);
|
||||||
|
DrawText("K: Zoom out", 5, halfScreenHeight + 16, 16, WHITE);
|
||||||
|
DrawText("P: Pause", 5, halfScreenHeight + 32, 16, WHITE);
|
||||||
|
DrawText("WASD: Move Camera", 5, halfScreenHeight + 48, 16, WHITE);
|
||||||
|
DrawText("ESC: Exit Game", 5, halfScreenHeight + 64, 16, WHITE);
|
||||||
|
|
||||||
|
if(IsKeyPressed(KEY_P)){
|
||||||
|
game->currentScreen = SCREEN_GAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Screen * InitScreen(Game *game, int id){
|
||||||
|
Screen *screen = malloc(sizeof(Screen));
|
||||||
|
|
||||||
|
screen->id = id;
|
||||||
|
screen->frameCounter = 0;
|
||||||
|
|
||||||
|
screen->uiContainer = UiContainerInitUiContainerForScreenID(game, id);
|
||||||
|
|
||||||
|
switch(id){
|
||||||
|
case SCREEN_EXIT:
|
||||||
|
screen->render = &ScreenRenderExitScreen;
|
||||||
|
break;
|
||||||
|
case SCREEN_MAINMENU:
|
||||||
|
screen->render = &ScreenRenderMainMenuScreen;
|
||||||
|
break;
|
||||||
|
case SCREEN_OPTIONS:
|
||||||
|
screen->render = &ScreenRenderEmptyScreen;
|
||||||
|
break;
|
||||||
|
case SCREEN_GAME:
|
||||||
|
screen->render = &ScreenRenderGameScreen;
|
||||||
|
break;
|
||||||
|
case SCREEN_PAUSE:
|
||||||
|
screen->render = &ScreenRenderPauseScreen;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("WARNING: Creating Screen of ID %d (NOT SUPPORTED) \n", id);
|
||||||
|
screen->render = &ScreenRenderEmptyScreen;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return screen;
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef SCREEN_H_
|
||||||
|
#define SCREEN_H_
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "../Ui/uiContainer.h"
|
||||||
|
#include "../game.h"
|
||||||
|
|
||||||
|
typedef struct Screen {
|
||||||
|
int id;
|
||||||
|
UiContainer *uiContainer;
|
||||||
|
|
||||||
|
float frameCounter;
|
||||||
|
|
||||||
|
void (*render)(Game *game); // Funktioneen in screen.c
|
||||||
|
} Screen;
|
||||||
|
|
||||||
|
Screen *InitScreen(Game *game, int id);
|
||||||
|
|
||||||
|
void ScreenRenderEmptyScreen(Game *game);
|
||||||
|
void ScreenRenderGameScreen(Game *game);
|
||||||
|
void ScreenRenderMainMenuScreen(Game *game);
|
||||||
|
void ScreenRenderPauseScreen(Game *game);
|
||||||
|
void ScreenRenderOptionsScreen(Game *game);
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Reference in new issue