Add signal handler

This commit is contained in:
Miloslav Číž 2020-10-03 21:26:48 +02:00
parent 071ca8ec69
commit 96ea7246ae

View File

@ -44,6 +44,7 @@
damage to make it a bit harder.
*/
#define SFG_PLAYER_DAMAGE_MULTIPLIER 1024
#define SFG_DITHERED_SHADOW 1
#define MUSIC_VOLUME 64
@ -277,6 +278,8 @@ void mainLoopIteration()
else if (event.wheel.y < 0) // scroll down
sdlMouseWheelState--;
}
else if (event.type == SDL_QUIT)
running = 0;
}
sdlMouseButtonState = SDL_GetMouseState(NULL,NULL);
@ -342,6 +345,11 @@ void SFG_playSound(uint8_t soundIndex, uint8_t volume)
}
}
void handleSignal(int signal)
{
running = 0;
}
int main(int argc, char *argv[])
{
uint8_t argHelp = 0;
@ -386,7 +394,7 @@ int main(int argc, char *argv[])
puts("SDL: initializing SDL");
SFG_init();
SFG_init(SDL_INIT_EVERYTHING);
window =
SDL_CreateWindow("raycasting", SDL_WINDOWPOS_UNDEFINED,
@ -417,6 +425,10 @@ int main(int argc, char *argv[])
SDL_Init(SDL_INIT_AUDIO);
signal(SIGINT,handleSignal);
signal(SIGQUIT,handleSignal);
signal(SIGTERM,handleSignal);
SDL_AudioSpec audioSpec;
SDL_memset(&audioSpec, 0, sizeof(audioSpec));