Files
JailAudioSDL3/main.cpp

42 lines
1.0 KiB
C++

#include "jail_audio.h"
#include <stdlib.h>
#include <SDL2/SDL.h>
SDL_Event event;
SDL_Window *sdlWindow;
int main(int argc, char **argv) {
SDL_Init(SDL_INIT_EVERYTHING);
sdlWindow = SDL_CreateWindow("JailAudio", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 240, SDL_WINDOW_SHOWN);
JA_Init(48000, AUDIO_S16, 2);
JA_Music music = JA_LoadMusic("intro2.ogg");
JA_Sound peiv = JA_LoadSound("menu_select.wav");
JA_PlayMusic(music, true);
bool should_exit = false;
while(!should_exit) {
while(SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) { should_exit = true; break; }
if (event.type == SDL_KEYDOWN) {
JA_PlaySound(peiv, 2);
if (JA_IsMusicPlaying())
JA_PauseMusic();
else
{
JA_ResumeMusic();
}
}
}
}
JA_DeleteSound(peiv);
JA_DeleteMusic(music);
SDL_DestroyWindow(sdlWindow);
SDL_Quit();
return 0;
}