Reposition stars on resize
This commit is contained in:
parent
46ffc40592
commit
135a64e178
21
src/game.c
21
src/game.c
|
@ -175,12 +175,7 @@ void game_init()
|
||||||
player.weaponType[0] = W_PLAYER_WEAPON;
|
player.weaponType[0] = W_PLAYER_WEAPON;
|
||||||
player.weaponType[1] = W_ROCKETS;
|
player.weaponType[1] = W_ROCKETS;
|
||||||
|
|
||||||
for (int i = 0 ; i < STARS_NUM ; i++)
|
game_setStars();
|
||||||
{
|
|
||||||
stars[i].x = rand() % screen->w;
|
|
||||||
stars[i].y = rand() % screen->h;
|
|
||||||
stars[i].speed = 1 + (rand() % 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
weapons_init();
|
weapons_init();
|
||||||
mission_init();
|
mission_init();
|
||||||
|
@ -228,6 +223,19 @@ static void game_addDebris(int x, int y, int amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sets star positions. Must do this any time the window size changes.
|
||||||
|
*/
|
||||||
|
void game_setStars()
|
||||||
|
{
|
||||||
|
for (int i = 0 ; i < STARS_NUM ; i++)
|
||||||
|
{
|
||||||
|
stars[i].x = rand() % screen->w;
|
||||||
|
stars[i].y = rand() % screen->h;
|
||||||
|
stars[i].speed = 1 + (rand() % 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Simply draws the stars in their positions on screen and moves
|
Simply draws the stars in their positions on screen and moves
|
||||||
them around.
|
them around.
|
||||||
|
@ -2789,6 +2797,7 @@ int game_mainLoop()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
player_getInput();
|
||||||
LIMIT_ADD(engine.musicVolume, -0.2, 0, 100);
|
LIMIT_ADD(engine.musicVolume, -0.2, 0, 100);
|
||||||
audio_setMusicVolume(engine.musicVolume);
|
audio_setMusicVolume(engine.musicVolume);
|
||||||
if (SDL_GetTicks() >= engine.missionCompleteTimer)
|
if (SDL_GetTicks() >= engine.missionCompleteTimer)
|
||||||
|
|
|
@ -99,6 +99,7 @@ extern Game game;
|
||||||
extern char game_systemNames[SYSTEM_MAX][STRMAX_SHORT];
|
extern char game_systemNames[SYSTEM_MAX][STRMAX_SHORT];
|
||||||
|
|
||||||
void game_init();
|
void game_init();
|
||||||
|
void game_setStars();
|
||||||
void game_doStars();
|
void game_doStars();
|
||||||
void game_doExplosions();
|
void game_doExplosions();
|
||||||
void game_delayFrame();
|
void game_delayFrame();
|
||||||
|
|
|
@ -458,6 +458,7 @@ void player_getInput()
|
||||||
if (engine.event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
|
if (engine.event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
|
||||||
{
|
{
|
||||||
screen_adjustDimensions(engine.event.window.data1, engine.event.window.data2);
|
screen_adjustDimensions(engine.event.window.data1, engine.event.window.data2);
|
||||||
|
game_setStars();
|
||||||
renderer_reset();
|
renderer_reset();
|
||||||
gfx_scaleBackground();
|
gfx_scaleBackground();
|
||||||
screen_clear(black);
|
screen_clear(black);
|
||||||
|
|
Loading…
Reference in New Issue