#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
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);
+ }
// ------------------------------
}
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)) {
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);
}
}