#include "game/camera.h"
#include "game/level.h"
#include "game/level/background.h"
+#include "game/level/boxes.h"
#include "game/level/goals.h"
#include "game/level/lava.h"
#include "game/level/platforms.h"
color_t background_color;
platforms_t *back_platforms;
background_t *background;
+ boxes_t *boxes;
};
level_t *create_level_from_file(const char *file_name)
RETURN_LT(lt, NULL);
}
+ level->boxes = PUSH_LT(lt, create_boxes_from_stream(level_file), destroy_boxes);
+ if (level->boxes == NULL) {
+ RETURN_LT(lt, NULL);
+ }
+
level->background = PUSH_LT(lt, create_background(level->background_color), destroy_background);
if (level->background == NULL) {
RETURN_LT(lt, NULL);
return -1;
}
- const rect_t view_port = camera_view_port(camera);
-
- background_move_to(level->background, vec(view_port.x + view_port.w * 0.5f,
- view_port.y + view_port.h * 0.5f));
-
if (background_render(level->background, camera) < 0) {
return -1;
}
return -1;
}
+ if (boxes_render(level->boxes, camera) < 0) {
+ return -1;
+ }
+
if (lava_render(level->lava, camera) < 0) {
return -1;
}
assert(level);
assert(delta_time > 0);
+ boxes_update(level->boxes, level->platforms, delta_time);
player_update(level->player, level->platforms, delta_time);
player_hide_goals(level->player, level->goals);
}
level->back_platforms = RESET_LT(level->lt, level->back_platforms, back_platforms);
+ boxes_t * const boxes = create_boxes_from_stream(level_file);
+ if (level->boxes == NULL) {
+ RETURN_LT(lt, -1);
+ }
+ level->boxes = RESET_LT(level->lt, level->boxes, boxes);
+
RETURN_LT(lt, 0);
}
-int level_sound(level_t *level, sound_medium_t *sound_medium)
+int level_sound(level_t *level, sound_samples_t *sound_samples)
{
- if (goals_sound(level->goals, sound_medium) < 0) {
+ if (goals_sound(level->goals, sound_samples) < 0) {
return -1;
}
- if (player_sound(level->player, sound_medium) < 0) {
+ if (player_sound(level->player, sound_samples) < 0) {
return -1;
}