diff --git a/CMakeLists.txt b/CMakeLists.txt index f7528dc..ae7d17d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,6 @@ set(SRC # add the executable add_executable(FLOPPE_FION ${SRC}) -target_link_libraries(FLOPPE_FION SDL2 SDL_image SDL2_ttf pthread m) +target_link_libraries(FLOPPE_FION SDL2 SDL_image SDL2_ttf SDL2_mixer pthread m) set_property(TARGET FLOPPE_FION PROPERTY C_STANDARD 23) diff --git a/assets/music/jojo arab.mp3 b/assets/music/jojo arab.mp3 new file mode 100644 index 0000000..38f5ee5 Binary files /dev/null and b/assets/music/jojo arab.mp3 differ diff --git a/assets/music/pet.mp3 b/assets/music/pet.mp3 new file mode 100644 index 0000000..1b1da82 Binary files /dev/null and b/assets/music/pet.mp3 differ diff --git a/assets/music/test.mp3 b/assets/music/test.mp3 new file mode 100644 index 0000000..2f99f26 Binary files /dev/null and b/assets/music/test.mp3 differ diff --git a/src/main.c b/src/main.c index 5a0eb2b..b4ad4f7 100644 --- a/src/main.c +++ b/src/main.c @@ -1,17 +1,36 @@ #include "renderer.h" #include "text.h" +#include + int main(void) { renderer_main(); + Mix_Init(MIX_INIT_MP3); + if(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096) != 0){ + printf("Music sound could not be open!\n" + "SDL_Error: %s\n", Mix_GetError()); + return 0; + } + + Mix_Music *music = Mix_LoadMUS("../assets/music/test.mp3"); + if(Mix_PlayMusic(music, -1) != 0){ + printf("Music sound could not be played!\n" + "SDL_Error: %s\n", Mix_GetError()); + Mix_FreeMusic(music); + return 0; + } + RenderObject_t text; SDL_Color white = {128, 128, 128, 128}; TTF_Init(); - if(text_renderText(&text, 0.f, 0.f, 1, white, "/home/gryf/.local/share/fonts/ARIAL.TTF", 25, "Hello World") < 0){ + if(text_renderText(&text, 0.f, 0.f, 1, white, "ARIAL.TTF", 25, "Hello World") < 0){ printf("error"); exit(1); } renderer_renderObject(text); while(1); + Mix_FreeMusic(music); + Mix_CloseAudio(); text_freeFontCache(); }