Made the window resizable.

This commit is contained in:
Julie Marchant 2019-05-30 12:29:47 -04:00
parent 7296b8ab76
commit f10af4aaf3
2 changed files with 15 additions and 1 deletions

View File

@ -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);
}

View File

@ -25,10 +25,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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;