diff --git a/CMakeLists.txt b/CMakeLists.txt index 52be6ed..0b112f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,15 +8,22 @@ if(CMAKE_BUILD_TYPE MATCHES DEBUG) add_link_options(-fsanitize=address) endif() -set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmaybe-uninitialized -Wno-unused-variable") -set(CMAKE_C_FLAGS_DEBUG "-g -Werror -O0") -set(CMAKE_C_FLAGS_RELEASE "") + +if(MINGW) + set(CMAKE_C_FLAGS "-Wno-undef --static -windows") + set(CMAKE_C_FLAGS_DEBUG "-g -O0") + set(CMAKE_C_FLAGS_RELEASE "-O2") +else() + set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmaybe-uninitialized -Wno-unused-variable") + set(CMAKE_C_FLAGS_DEBUG "-g -Werror -O0") + set(CMAKE_C_FLAGS_RELEASE "") +endif() # generate the compile_commands for vscode / clang set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") # set the project name -project(FLOPPE_FION) +project(LEGEND_OF_ADAME) set(SRC @@ -32,13 +39,17 @@ set(SRC ) # add the executable -add_executable(FLOPPE_FION ${SRC}) +add_executable(LEGEND_OF_ADAME ${SRC}) -target_link_libraries(FLOPPE_FION SDL2 SDL2_image SDL2_ttf SDL2_mixer m) +target_link_libraries(LEGEND_OF_ADAME SDL2 SDL2_image SDL2_ttf SDL2_mixer m) -set_property(TARGET FLOPPE_FION PROPERTY C_STANDARD 23) +set_property(TARGET LEGEND_OF_ADAME PROPERTY C_STANDARD 23) file(COPY assets DESTINATION ${CMAKE_BINARY_DIR}) + +if(MINGW) + target_link_libraries(LEGEND_OF_ADAME ws2_32 windows mingw32 SDLmain SDL) +endif() diff --git a/assets/music/test.mp3 b/assets/music/the truth.mp3 similarity index 100% rename from assets/music/test.mp3 rename to assets/music/the truth.mp3 diff --git a/src/game.c b/src/game.c index 516f290..d239e84 100644 --- a/src/game.c +++ b/src/game.c @@ -102,7 +102,7 @@ static void playMusic(){ exit(1); } - if(Mix_PlayMusic(music, 0) != 0){ + if(Mix_PlayMusic(music, -1) != 0){ printf("Music sound could not be played!\n" "SDL_Error: %s\n", Mix_GetError()); Mix_FreeMusic(music); @@ -124,6 +124,7 @@ int game_staticRender(void){ return -1; } + SDL_Surface* gameBackgroundSurface2 = IMG_Load("./assets/img/game_bg.png"); RenderObject_t gameBackground = EMPTY_RENDER_OBJECT; strcpy(gameBackground.name, "gameBackground"); @@ -132,6 +133,7 @@ int game_staticRender(void){ scaller(gameBackground.surface, 1, &gameBackground.width, &gameBackground.height); gameBackground.height = 1; backgrounds[0] = scene_addRenderObject(&gameScene, gameBackground, 0, 0); + gameBackground.surface = gameBackgroundSurface2; backgrounds[1] = scene_addRenderObject(&gameScene, gameBackground, gameBackground.width * CAMERA_WIDTH, 0); backgroundStep = gameBackground.width * CAMERA_WIDTH; diff --git a/src/main.c b/src/main.c index 24184ea..e8ad765 100644 --- a/src/main.c +++ b/src/main.c @@ -79,4 +79,5 @@ int main(int argc, char ** argv) { Mix_CloseAudio(); text_freeFontCache(); + return 0; } diff --git a/src/scene.c b/src/scene.c index 5831921..dc9a4fc 100644 --- a/src/scene.c +++ b/src/scene.c @@ -7,6 +7,7 @@ #include #include #include +#include const RenderObject_t EMPTY_RENDER_OBJECT = { 0, 0.f, 0.f, 0.f, 0.f, 0.f, NULL, "Undefined" }; @@ -82,7 +83,11 @@ RenderId_t scene_addRenderObject(Scene_t * scene, RenderObject_t object, int x, scene->objects[scene->objectCount - 1] = item; //the objects are sorted + #ifdef __MINGW32__ + qsort(scene->objects, scene->objectCount, sizeof(SceneObject_t), (int (__cdecl *)(const void *,const void *))compartSort); + #else qsort(scene->objects, scene->objectCount, sizeof(SceneObject_t), (__compar_fn_t)compartSort); + #endif return itemId; } @@ -121,6 +126,9 @@ void scene_removeRenderObject(Scene_t * scene, RenderId_t id) { scene->objectCount--; + SDL_DestroyTexture(scene->objects[index].cache); + SDL_FreeSurface(scene->objects[index].renderObj.surface); + for(int i = index; i < scene->objectCount; i++) { scene->objects[i] = scene->objects[i + 1]; }