Files
punk-n-spray-raylib-c/src/core/window.c

80 lines
2.2 KiB
C

#include "window.h"
const char *TITLE = "Punk n' Spray";
const int WIDTH = 900;
const int HEIGHT = 600;
Result InitGameWindow(void) {
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
InitWindow(WIDTH, HEIGHT, TITLE);
if (!IsWindowReady())
return RESULT_INIT_FAILED;
return RESULT_OK;
}
void HandleWindowEvents() {
if (IsKeyPressed(KEY_F11))
{
int display = GetCurrentMonitor();
if (IsWindowFullscreen())
{
SetWindowSize(WIDTH, HEIGHT);
}
else
{
SetWindowSize(GetMonitorWidth(display), GetMonitorHeight(display));
}
ToggleFullscreen();
}
}
void ShowSplashScreen(void) {
Image logoImg = LoadImage("resources/images/PunkNSpray.png");
Image miarmaImg = LoadImage("resources/images/Miarma.png");
ImageResize(&miarmaImg, 64, 64);
Texture2D logo = LoadTextureFromImage(logoImg);
Texture2D miarma = LoadTextureFromImage(miarmaImg);
UnloadImage(logoImg);
UnloadImage(miarmaImg);
Font font = LoadFontEx("resources/fonts/CyberpunkRegular.ttf", 24, NULL, 0);
float timer = 0.0f;
const float duration = 3.0f;
while (timer < duration && !WindowShouldClose()) {
BeginDrawing();
ClearBackground(WHITE);
// logo juego centrado
int logoX = (WIDTH - logo.width) / 2;
int logoY = (HEIGHT - logo.height) / 2 - 40;
DrawTexture(logo, logoX, logoY, WHITE);
// texto centrado encima del logo
const char *text = "Desarrollado por";
int textWidth = MeasureText(text, 24);
int textX = (WIDTH - textWidth) / 2 - 20;
int textY = logoY + logo.height - 30;
DrawTextEx(font, text, (Vector2){(float)textX, (float)textY},
(float)font.baseSize, 2, BLACK);
// logo miarma centrado debajo del texto
int miarmaX = (WIDTH - miarma.width) / 2;
int miarmaY = textY + 20;
DrawTexture(miarma, miarmaX, miarmaY, WHITE);
timer += GetFrameTime();
EndDrawing();
}
UnloadTexture(logo);
UnloadTexture(miarma);
UnloadFont(font);
}