aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 17:42:07 +0000
committernathansmith117 <thenathansmithsmith@gmail.com>2024-02-21 17:42:07 +0000
commitba522d0b6e8172d2d9f0ee107fbb2d6499380847 (patch)
tree7727c315be6e02261bd3a55a6c25901f2d327963
parentecb467030530f54dfcf530132c4cd7194dc0f484 (diff)
downloadPenguinYippies-ba522d0b6e8172d2d9f0ee107fbb2d6499380847.tar.gz
PenguinYippies-ba522d0b6e8172d2d9f0ee107fbb2d6499380847.tar.bz2
PenguinYippies-ba522d0b6e8172d2d9f0ee107fbb2d6499380847.zip
Working on resizing thingy
-rw-r--r--src/game.c21
-rw-r--r--src/game.h3
-rw-r--r--src/gameCommon.h4
-rw-r--r--src/gameScreen.c6
-rw-r--r--src/mainMenu.c4
5 files changed, 30 insertions, 8 deletions
diff --git a/src/game.c b/src/game.c
index cecca65..e74075f 100644
--- a/src/game.c
+++ b/src/game.c
@@ -3,6 +3,7 @@
void initGame(Game* game)
{
InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Penguin Yippies!");
+ SetWindowState(FLAG_WINDOW_RESIZABLE);
// Assets.
initAssets(&game->assets);
@@ -11,11 +12,14 @@ void initGame(Game* game)
game->currentScreen = MAIN_MENU_SCREEN;
initMainMenu(&game->mainMenu, game);
initGameScreen(&game->gameScreen, game);
+
+ game->screenTexture = LoadRenderTexture(WINDOW_WIDTH, WINDOW_HEIGHT);
}
void updateGame(Game* game)
{
- BeginDrawing();
+ // Draw screen.
+ BeginTextureMode(game->screenTexture);
switch (game->currentScreen)
{
@@ -29,6 +33,20 @@ void updateGame(Game* game)
break;
}
+ EndTextureMode();
+
+ // Draw the silly silly render texture.
+ BeginDrawing();
+
+ DrawTexturePro(
+ game->screenTexture.texture,
+ (Rectangle){0.0, 0.0, game->screenTexture.texture.width, -game->screenTexture.texture.height},
+ (Rectangle){0.0, 0.0, GetScreenWidth(), GetScreenHeight()},
+ Vector2Zero(),
+ 0.0,
+ WHITE
+ );
+
EndDrawing();
}
@@ -37,6 +55,7 @@ void closeGame(Game* game)
closeAssets(&game->assets);
closeMainMenu(&game->mainMenu);
closeGameScreen(&game->gameScreen);
+ UnloadRenderTexture(game->screenTexture);
CloseWindow();
}
diff --git a/src/game.h b/src/game.h
index 81cfa67..7b8d145 100644
--- a/src/game.h
+++ b/src/game.h
@@ -18,6 +18,9 @@ typedef struct Game {
ScreenId currentScreen;
MainMenu mainMenu;
GameScreen gameScreen;
+
+ // Wacky little render texture to make it look more like a unity game lmao.
+ RenderTexture screenTexture;
} Game;
void initGame(Game* game);
diff --git a/src/gameCommon.h b/src/gameCommon.h
index 1a9edea..ceca8b8 100644
--- a/src/gameCommon.h
+++ b/src/gameCommon.h
@@ -6,8 +6,8 @@
#include <raylib.h>
#include <raymath.h>
-#define WINDOW_WIDTH 1366
-#define WINDOW_HEIGHT 768
+#define WINDOW_WIDTH 1280
+#define WINDOW_HEIGHT 720
#ifndef GAME_COMMON_H
#define GAME_COMMON_H
diff --git a/src/gameScreen.c b/src/gameScreen.c
index 005becc..dc14bc1 100644
--- a/src/gameScreen.c
+++ b/src/gameScreen.c
@@ -5,8 +5,8 @@
void initGameScreen(GameScreen* gameScreen, Game* game)
{
Assets* assets = &game->assets;
- int width = GetScreenWidth();
- int height = GetScreenHeight();
+ int width = WINDOW_WIDTH;
+ int height = WINDOW_HEIGHT;
int navigationButtonSize = 100;
int navigationButtonX = width - navigationButtonSize - 5.0;
@@ -33,7 +33,7 @@ void initGameScreen(GameScreen* gameScreen, Game* game)
Texture* buttonTexture = &gameScreen->buttonPanelSharedAnimation.texture;
int buttonWidth = width / 4;
- int buttonHeight = buttonWidth / 2.0;
+ int buttonHeight = buttonWidth / 2;
int buttonY = height - buttonHeight;
gameScreen->upgradesButton = createTexturedButton(
diff --git a/src/mainMenu.c b/src/mainMenu.c
index f64c2be..4968ee7 100644
--- a/src/mainMenu.c
+++ b/src/mainMenu.c
@@ -14,8 +14,8 @@ void initMainMenu(MainMenu* mainMenu, Game* game)
Texture* startButtonTexture = &mainMenu->startButtonAnimation.texture;
- int width = GetScreenWidth();
- int height = GetScreenHeight();
+ int width = WINDOW_WIDTH;
+ int height = WINDOW_HEIGHT;
mainMenu->startButton = createTexturedButton(
startButtonTexture,