Revert "Make platforms a transparent entity"
This reverts commit af2244518b05095825e10fc155208e0331a08a36. It's not really needed to achive what I'm trying to achive
This commit is contained in:
parent
af2244518b
commit
40004db6af
@ -41,10 +41,10 @@ struct Level
|
||||
Background background;
|
||||
RigidBodies *rigid_bodies;
|
||||
Player *player;
|
||||
Platforms platforms;
|
||||
Platforms *platforms;
|
||||
Goals *goals;
|
||||
Lava *lava;
|
||||
Platforms back_platforms;
|
||||
Platforms *back_platforms;
|
||||
Boxes *boxes;
|
||||
Labels *labels;
|
||||
Regions *regions;
|
||||
@ -84,7 +84,13 @@ Level *create_level_from_level_editor(const LevelEditor *level_editor)
|
||||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
|
||||
level->platforms = create_platforms_from_rect_layer(level_editor->platforms_layer);
|
||||
level->platforms = PUSH_LT(
|
||||
lt,
|
||||
create_platforms_from_rect_layer(level_editor->platforms_layer),
|
||||
destroy_platforms);
|
||||
if (level->platforms == NULL) {
|
||||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
|
||||
level->goals = PUSH_LT(
|
||||
lt,
|
||||
@ -102,8 +108,13 @@ Level *create_level_from_level_editor(const LevelEditor *level_editor)
|
||||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
|
||||
level->back_platforms =
|
||||
create_platforms_from_rect_layer(level_editor->back_platforms_layer);
|
||||
level->back_platforms = PUSH_LT(
|
||||
lt,
|
||||
create_platforms_from_rect_layer(level_editor->back_platforms_layer),
|
||||
destroy_platforms);
|
||||
if (level->back_platforms == NULL) {
|
||||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
|
||||
level->boxes = PUSH_LT(
|
||||
lt,
|
||||
@ -149,7 +160,7 @@ int level_render(const Level *level, const Camera *camera)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (platforms_render(&level->back_platforms, camera) < 0) {
|
||||
if (platforms_render(level->back_platforms, camera) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -165,7 +176,7 @@ int level_render(const Level *level, const Camera *camera)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (platforms_render(&level->platforms, camera) < 0) {
|
||||
if (platforms_render(level->platforms, camera) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -199,7 +210,7 @@ int level_update(Level *level, float delta_time)
|
||||
boxes_update(level->boxes, delta_time);
|
||||
player_update(level->player, delta_time);
|
||||
|
||||
rigid_bodies_collide(level->rigid_bodies, &level->platforms);
|
||||
rigid_bodies_collide(level->rigid_bodies, level->platforms);
|
||||
|
||||
player_die_from_lava(level->player, level->lava);
|
||||
regions_player_enter(level->regions, level->player);
|
||||
|
@ -12,32 +12,51 @@
|
||||
#include "game/level/level_editor/rect_layer.h"
|
||||
#include "math/extrema.h"
|
||||
|
||||
Platforms create_platforms_from_rect_layer(const RectLayer *layer)
|
||||
struct Platforms {
|
||||
Lt *lt;
|
||||
|
||||
Rect *rects;
|
||||
Color *colors;
|
||||
size_t rects_size;
|
||||
};
|
||||
|
||||
Platforms *create_platforms_from_rect_layer(const RectLayer *layer)
|
||||
{
|
||||
trace_assert(layer);
|
||||
|
||||
Platforms platforms = {0};
|
||||
platforms.rects_size = rect_layer_count(layer);
|
||||
Lt *lt = create_lt();
|
||||
|
||||
platforms.rects = nth_calloc(1, sizeof(Rect) * platforms.rects_size);
|
||||
memcpy(
|
||||
platforms.rects,
|
||||
rect_layer_rects(layer),
|
||||
sizeof(Rect) * platforms.rects_size);
|
||||
Platforms *platforms = PUSH_LT(
|
||||
lt,
|
||||
nth_calloc(1, sizeof(Platforms)),
|
||||
free);
|
||||
if (platforms == NULL) {
|
||||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
platforms->lt = lt;
|
||||
|
||||
platforms.colors = nth_calloc(1, sizeof(Color) * platforms.rects_size);
|
||||
memcpy(
|
||||
platforms.colors,
|
||||
rect_layer_colors(layer),
|
||||
sizeof(Color) * platforms.rects_size);
|
||||
platforms->rects_size = rect_layer_count(layer);
|
||||
|
||||
platforms->rects = PUSH_LT(lt, nth_calloc(1, sizeof(Rect) * platforms->rects_size), free);
|
||||
if (platforms->rects == NULL) {
|
||||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
memcpy(platforms->rects, rect_layer_rects(layer), sizeof(Rect) * platforms->rects_size);
|
||||
|
||||
|
||||
platforms->colors = PUSH_LT(lt, nth_calloc(1, sizeof(Color) * platforms->rects_size), free);
|
||||
if (platforms->colors == NULL) {
|
||||
RETURN_LT(lt, NULL);
|
||||
}
|
||||
memcpy(platforms->colors, rect_layer_colors(layer), sizeof(Color) * platforms->rects_size);
|
||||
|
||||
return platforms;
|
||||
}
|
||||
|
||||
void destroy_platforms(Platforms platforms)
|
||||
void destroy_platforms(Platforms *platforms)
|
||||
{
|
||||
free(platforms.rects);
|
||||
free(platforms.colors);
|
||||
trace_assert(platforms);
|
||||
RETURN_LT0(platforms->lt);
|
||||
}
|
||||
|
||||
int platforms_render(const Platforms *platforms,
|
||||
|
@ -6,16 +6,11 @@
|
||||
#include "game/camera.h"
|
||||
#include "math/rect.h"
|
||||
|
||||
typedef struct Platforms Platforms;
|
||||
typedef struct RectLayer RectLayer;
|
||||
|
||||
typedef struct {
|
||||
Rect *rects;
|
||||
Color *colors;
|
||||
size_t rects_size;
|
||||
} Platforms;
|
||||
|
||||
Platforms create_platforms_from_rect_layer(const RectLayer *layer);
|
||||
void destroy_platforms(Platforms platforms);
|
||||
Platforms *create_platforms_from_rect_layer(const RectLayer *layer);
|
||||
void destroy_platforms(Platforms *platforms);
|
||||
|
||||
int platforms_render(const Platforms *platforms,
|
||||
const Camera *camera);
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define RIGID_BODIES_H_
|
||||
|
||||
#include "math/mat3x3.h"
|
||||
#include "game/level/platforms.h"
|
||||
|
||||
typedef struct RigidBodies RigidBodies;
|
||||
typedef struct Platforms Platforms;
|
||||
|
||||
typedef size_t RigidBodyId;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user