]> git.lizzy.rs Git - nothing.git/blobdiff - src/main.c
Remove redundant logging
[nothing.git] / src / main.c
index e2e8127a0bcf56f067d6fc5032e47e781420d3c3..40bfd880d855c481fb12892349a0adcdee323ccd 100644 (file)
@@ -4,14 +4,14 @@
 #include <SDL2/SDL.h>
 #include <SDL2/SDL_mixer.h>
 
-#include "./player.h"
+#include "./game/level/player.h"
 #include "./platforms.h"
 #include "./error.h"
 #include "./game.h"
 #include "./lt.h"
 #include "./path.h"
 #include "./point.h"
-#include "./sound_medium.h"
+#include "./game/sound_medium.h"
 
 #define SCREEN_WIDTH 800
 #define SCREEN_HEIGHT 600
@@ -118,7 +118,14 @@ int main(int argc, char *argv[])
     const size_t sound_samples_count = sizeof(sound_samples) / sizeof(Mix_Chunk*);
 
     sound_medium_t *sound_medium =
-        PUSH_LT(lt, create_sound_medium(sound_samples, sound_samples_count), destroy_sound_medium);
+        PUSH_LT(
+            lt,
+            create_sound_medium(sound_samples, sound_samples_count, 0, MIX_CHANNELS - 1),
+            destroy_sound_medium);
+    if (sound_medium == NULL) {
+        print_current_error_msg("Could not create sound medium");
+        RETURN_LT(lt, -1);
+    }
 
     // ------------------------------
 
@@ -135,7 +142,7 @@ int main(int argc, char *argv[])
     }
 
     const Uint8 *const keyboard_state = SDL_GetKeyboardState(NULL);
-    const Uint32 delay_ms = (Uint32) roundf(1000.0f / GAME_FPS);
+    const float delay_ms = 1.0f / GAME_FPS;
     SDL_Event e;
     while (!game_over_check(game)) {
         while (!game_over_check(game) && SDL_PollEvent(&e)) {
@@ -150,13 +157,18 @@ int main(int argc, char *argv[])
             RETURN_LT(lt, -1);
         }
 
+        if (game_render(game, renderer) < 0) {
+            print_current_error_msg("Failed rendering the game");
+            RETURN_LT(lt, -1);
+        }
+
         if (game_update(game, delay_ms) < 0) {
             print_current_error_msg("Failed handling updating");
             RETURN_LT(lt, -1);
         }
 
-        if (game_render(game, renderer) < 0) {
-            print_current_error_msg("Failed rendering the game");
+        if (game_sound(game) < 0) {
+            print_current_error_msg("Failed handling the sound");
             RETURN_LT(lt, -1);
         }
     }