From f10af4aaf3765692e4951edce09260dde87985d2 Mon Sep 17 00:00:00 2001 From: Julie Marchant Date: Thu, 30 May 2019 12:29:47 -0400 Subject: [PATCH] Made the window resizable. --- src/engine.c | 6 +++++- src/player.c | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/engine.c b/src/engine.c index 2abcf79..be1ba39 100644 --- a/src/engine.c +++ b/src/engine.c @@ -277,7 +277,9 @@ void engine_setMode() exit(1); } - window = SDL_CreateWindow("Project: Starfighter", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen->w, screen->h, 0); + window = SDL_CreateWindow("Project: Starfighter", + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + screen->w, screen->h, SDL_WINDOW_RESIZABLE); if (window == NULL) { printf("Could not create window: %s\n", SDL_GetError()); @@ -329,6 +331,8 @@ void engine_setFullscreen(int value) // Clear the screen (prevents artifacts) screen_clear(black); renderer_update(); + screen_clear(black); + screen_addBuffer(0, 0, screen->w, screen->h); SDL_SetWindowFullscreen(window, engine.fullScreen ? FULLSCREEN : 0); } diff --git a/src/player.c b/src/player.c index 0afc34f..aaa21fb 100644 --- a/src/player.c +++ b/src/player.c @@ -25,10 +25,12 @@ along with this program. If not, see . #include "alien.h" #include "audio.h" #include "engine.h" +#include "colors.h" #include "game.h" #include "gfx.h" #include "info.h" #include "player.h" +#include "renderer.h" #include "screen.h" #include "weapons.h" #include "window.h" @@ -333,6 +335,14 @@ void player_getInput() break; case SDL_WINDOWEVENT: + if (engine.event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) + { + screen_clear(black); + renderer_update(); + screen_clear(black); + screen_addBuffer(0, 0, screen->w, screen->h); + } + if (engine.autoPause && (engine.event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)) engine.paused = 1;