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.
169 lines
4.5 KiB
169 lines
4.5 KiB
#include "raylib.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/buttons.h"
|
|
|
|
int main(){
|
|
|
|
InitWindow(1600, 900, "basic window");
|
|
|
|
Game *game = GameInit();
|
|
|
|
// Hides the operating systems own cursor
|
|
HideCursor();
|
|
|
|
SetTargetFPS(60);
|
|
|
|
|
|
return uitest(game);
|
|
// GAME MAIN ROUTINE
|
|
while(!WindowShouldClose()){
|
|
|
|
ListActAllSprites(game);
|
|
|
|
ClearBackground(RAYWHITE);
|
|
BeginDrawing();
|
|
|
|
BeginMode2D(*(game->camera));
|
|
|
|
//IsometricRendererRenderIsometricMap(game);
|
|
//ListDrawAllSprites(game->sprites, game->layers, game->camera);
|
|
IsometricMapDraw(game);
|
|
|
|
EndMode2D();
|
|
|
|
// Moving cursor Sprite to Mouse Pos and drawing it
|
|
game->cursorSprite->x = game->inputHandler->cursorPos.x;
|
|
game->cursorSprite->y = game->inputHandler->cursorPos.y;
|
|
DrawSpriteToScreen(game->cursorSprite);
|
|
|
|
// User Input Handling
|
|
mouseInput(game);
|
|
keyboardInput(game->inputHandler, game->camera);
|
|
|
|
DrawFPS(GetScreenWidth() - 95, 10);
|
|
|
|
EndDrawing();
|
|
|
|
}
|
|
|
|
CloseWindow();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
int uitest(Game * game){
|
|
|
|
Texture2D button = LoadTexture("assets/button.png");
|
|
Texture2D buttonHovered = LoadTexture("assets/button_hovered.png");
|
|
Texture2D buttonPressed = LoadTexture("assets/button_pressed.png");
|
|
|
|
Button continuebutton;
|
|
continuebutton.id = 0;
|
|
continuebutton.position = (Vector2){GetScreenWidth()/2, GetScreenHeight()/2};
|
|
continuebutton.state = 0;
|
|
|
|
continuebutton.textures[0] = &button;
|
|
continuebutton.textures[1] = &buttonHovered;
|
|
continuebutton.textures[2] = &buttonPressed;
|
|
|
|
while(!WindowShouldClose()){
|
|
|
|
// Moving cursor Sprite to Mouse Pos
|
|
game->cursorSprite->x = GetMousePosition().x;
|
|
game->cursorSprite->y = GetMousePosition().y;
|
|
|
|
switch(game->screen){
|
|
case SCREEN_EXIT:
|
|
return 0;
|
|
case SCREEN_MAINMENU:
|
|
printf("MAINMENU \n");
|
|
return 0;
|
|
case SCREEN_OPTIONS:
|
|
printf("OPTIONS \n");
|
|
return 0;
|
|
case SCREEN_GAME:
|
|
|
|
ListActAllSprites(game);
|
|
|
|
ClearBackground(RAYWHITE);
|
|
BeginDrawing();
|
|
|
|
BeginMode2D(*(game->camera));
|
|
|
|
//IsometricRendererRenderIsometricMap(game);
|
|
//ListDrawAllSprites(game->sprites, game->layers, game->camera);
|
|
IsometricMapDraw(game);
|
|
|
|
EndMode2D();
|
|
|
|
DrawSpriteToScreen(game->cursorSprite);
|
|
|
|
// User Input Handling
|
|
mouseInput(game);
|
|
keyboardInput(game->inputHandler, game->camera);
|
|
|
|
DrawFPS(GetScreenWidth() - 95, 10);
|
|
|
|
EndDrawing();
|
|
|
|
if(IsKeyPressed(KEY_P)){
|
|
game->screen = SCREEN_PAUSE;
|
|
}
|
|
|
|
break;
|
|
case SCREEN_PAUSE:
|
|
ClearBackground(RAYWHITE);
|
|
|
|
|
|
BeginDrawing();
|
|
|
|
BeginMode2D(*(game->camera));
|
|
IsometricMapDraw(game);
|
|
EndMode2D();
|
|
|
|
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);
|
|
|
|
printf("Vorher \n");
|
|
drawButton(&continuebutton);
|
|
printf("Nachher \n");
|
|
if(continuebutton.state == 2){
|
|
executeButton(&continuebutton, game);
|
|
}
|
|
|
|
DrawSpriteToScreen(game->cursorSprite);
|
|
DrawFPS(GetScreenWidth() - 95, 10);
|
|
|
|
EndDrawing();
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
CloseWindow();
|
|
|
|
return 0;
|
|
} |