@ -11,6 +11,7 @@
# include "Ui/button.h"
# include "Ui/uiContainer.h"
# include "Ui/debug.h"
# include "definitions.h"
// TODO: Variable die den Maus Input freigibt solange nichts mit der Maus gemacht wurde
// Sobald ein Button gedrückt wurde in diesem Frame oder rect gezogen wird oder so ist sind Maus Funktionen gesperrt
@ -26,7 +27,8 @@ int main(){
// Hides the operating systems own cursor
HideCursor ( ) ;
//SetTargetFPS(60);
//SetTargetFPS(50);
double frame = 0 ;
while ( ! WindowShouldClose ( ) ) {
@ -39,7 +41,6 @@ int main(){
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
@ -54,9 +55,11 @@ int main(){
return 0 ;
case SCREEN_GAME :
// Updating Entities
EntityListActAllEntities ( game ) ;
frame + = GetFrameTime ( ) ;
if ( frame > = ACT_TIME ) {
EntityListActAllEntities ( game ) ;
frame = 0 ;
}
// Drawing IsometricMap
BeginMode2D ( * ( game - > camera ) ) ; // Sorgt dafür, dass die Kameraposition beachtet wird
@ -69,13 +72,9 @@ int main(){
mouseInput ( game ) ;
keyboardInput ( game ) ;
if ( IsKeyPressed ( KEY_P ) ) {
game - > screen = SCREEN_PAUSE ;
}
break ;
case SCREEN_PAUSE :
int halfScreenHeight = GetScreenHeight ( ) / 2 ;
// Still drawing isometric map, which is not updated atm
BeginMode2D ( * ( game - > camera ) ) ; // Sorgt dafür, dass die Kameraposition beachtet wird
@ -85,15 +84,15 @@ int main(){
UiContainerDrawUiContainer ( game - > UiContainers [ SCREEN_GAME ] ) ;
// 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 ) ;
int textWidthHalf = ( MeasureText ( " Paused " , 28 ) / 2 ) ;
DrawText ( " Paused " , GetScreenWidth ( ) / 2 - textWidthHalf , ( halfScreenHeight / 2 ) - 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 ) ;
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 - > screen = SCREEN_GAME ;
@ -113,7 +112,6 @@ int main(){
// Dinge die grundsätzlich immer gedrawed werden sollen
// Debug Menu, FPS anzeige, Cursor
DebugDraw ( game ) ;
DrawFPS ( GetScreenWidth ( ) - 95 , 10 ) ;
DrawSpriteToScreen ( game - > cursorSprite ) ;
EndDrawing ( ) ;