forked from JailDoctor/JailAudio
- Exemple updatat a SDL3
This commit is contained in:
22
main.cpp
22
main.cpp
@@ -1,6 +1,6 @@
|
||||
#include "jail_audio.h"
|
||||
#include <stdlib.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <stdio.h>
|
||||
|
||||
SDL_Event event;
|
||||
@@ -8,12 +8,12 @@ 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);
|
||||
SDL_Init(SDL_INIT_AUDIO|SDL_INIT_EVENTS);
|
||||
sdlWindow = SDL_CreateWindow("JailAudio", 320, 240, 0);
|
||||
JA_Init(48000, SDL_AUDIO_S16, 2);
|
||||
|
||||
JA_Music music = JA_LoadMusic("intro2.ogg");
|
||||
JA_Sound peiv = JA_LoadSound("menu_select.wav");
|
||||
JA_Music_t *music = JA_LoadMusic("intro2.ogg");
|
||||
JA_Sound_t *peiv = JA_LoadSound("menu_select.wav");
|
||||
int channel = -1;
|
||||
|
||||
JA_PlayMusic(music, true);
|
||||
@@ -21,9 +21,9 @@ int main(int argc, char **argv) {
|
||||
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) {
|
||||
switch (event.key.keysym.scancode) {
|
||||
if (event.type == SDL_EVENT_QUIT) { should_exit = true; break; }
|
||||
if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||
switch (event.key.scancode) {
|
||||
case SDL_SCANCODE_1: // Si pulsem la tecla '1' pausem o despausem la música
|
||||
if (JA_GetMusicState() == JA_MUSIC_PLAYING) { JA_PauseMusic(); } else { JA_ResumeMusic(); }
|
||||
break;
|
||||
@@ -48,6 +48,9 @@ int main(int argc, char **argv) {
|
||||
case SDL_SCANCODE_DOWN:
|
||||
volume = JA_SetVolume(volume-16);
|
||||
break;
|
||||
case SDL_SCANCODE_ESCAPE:
|
||||
should_exit = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -57,6 +60,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
JA_DeleteSound(peiv);
|
||||
JA_DeleteMusic(music);
|
||||
JA_Quit();
|
||||
SDL_DestroyWindow(sdlWindow);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user