Wire up pp to level loop

master
rexim 2020-01-26 03:04:51 +07:00
parent 100d4dbc07
commit 4c093ee248
6 changed files with 17 additions and 9 deletions

View File

@ -43,6 +43,6 @@ box_0 -3923.780518 452.429810 112.500031 107.291695 a05034
0
0
3
pp_0 -104.841812 -42.929047 55.225319 53.499516 ff0000
pp_1 30.632792 -131.375824 56.951111 62.559914 ff0000
pp_2 59.539791 -29.554169 44.870571 75.071899 ff0000
pp_0 -116.490898 -97.722908 42.713326 84.995201 ff0000
pp_1 92.761269 -140.436234 31.927139 80.249283 ff0000
pp_2 30.632792 -16.610737 41.418991 59.971233 ff0000

View File

@ -49,4 +49,4 @@
#include "src/dynarray.c"
#include "src/system/file.c"
#include "src/ring_buffer.c"
#include "src/game/level/phantom_platforms.h"
#include "src/game/level/phantom_platforms.c"

View File

@ -10,6 +10,7 @@
#include "game/level/labels.h"
#include "game/level/lava.h"
#include "game/level/platforms.h"
#include "game/level/phantom_platforms.h"
#include "game/level/player.h"
#include "game/level/regions.h"
#include "game/level/rigid_bodies.h"
@ -48,6 +49,7 @@ struct Level
Boxes *boxes;
Labels *labels;
Regions *regions;
Phantom_Platforms pp;
};
Level *create_level_from_level_editor(const LevelEditor *level_editor)
@ -143,12 +145,15 @@ Level *create_level_from_level_editor(const LevelEditor *level_editor)
RETURN_LT(lt, NULL);
}
level->pp = create_phantom_platforms(level_editor->pp_layer);
return level;
}
void destroy_level(Level *level)
{
trace_assert(level);
destroy_phantom_platforms(level->pp);
RETURN_LT0(level->lt);
}
@ -164,6 +169,8 @@ int level_render(const Level *level, const Camera *camera)
return -1;
}
phantom_platforms_render(&level->pp, camera);
if (player_render(level->player, camera) < 0) {
return -1;
}
@ -221,8 +228,8 @@ int level_update(Level *level, float delta_time)
labels_update(level->labels, delta_time);
Rect hitbox = player_hitbox(level->player);
platforms_hide_platform_at(level->back_platforms, vec(hitbox.x, hitbox.y));
platforms_update(level->back_platforms, delta_time);
phantom_platforms_hide_at(&level->pp, vec(hitbox.x, hitbox.y));
phantom_platforms_update(&level->pp, delta_time);
return 0;
}

View File

@ -113,6 +113,7 @@ LevelEditor *create_level_editor_from_file(Memory *memory, Cursor *cursor, const
rect_layer_load(level_editor->boxes_layer, memory, &input);
label_layer_load(level_editor->label_layer, memory, &input);
rect_layer_load(level_editor->regions_layer, memory, &input);
rect_layer_load(level_editor->pp_layer, memory, &input);
undo_history_clean(level_editor->undo_history);
return level_editor;

View File

@ -23,7 +23,7 @@ void destroy_phantom_platforms(Phantom_Platforms pp)
free(pp.hiding);
}
void phantom_platforms_render(Phantom_Platforms *pp, Camera *camera)
void phantom_platforms_render(const Phantom_Platforms *pp, const Camera *camera)
{
trace_assert(pp);
trace_assert(camera);
@ -33,7 +33,7 @@ void phantom_platforms_render(Phantom_Platforms *pp, Camera *camera)
}
}
#define HIDING_SPEED 2.0f
#define HIDING_SPEED 4.0f
void phantom_platforms_update(Phantom_Platforms *pp, float dt)
{

View File

@ -11,7 +11,7 @@ typedef struct {
Phantom_Platforms create_phantom_platforms(RectLayer *rect_layer);
void destroy_phantom_platforms(Phantom_Platforms pp);
void phantom_platforms_render(Phantom_Platforms *pp, Camera *camera);
void phantom_platforms_render(const Phantom_Platforms *pp, const Camera *camera);
void phantom_platforms_update(Phantom_Platforms *pp, float dt);
void phantom_platforms_hide_at(Phantom_Platforms *pp, Vec2f position);