Compare commits
2 Commits
d4d3b317e2
...
c2c00cfa51
Author | SHA1 | Date |
---|---|---|
|
c2c00cfa51 | |
|
5398c08782 |
|
@ -439,7 +439,7 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
DrawText(buffer, gui_x + 80, gui_y, 12, BLACK);
|
DrawText(buffer, gui_x + 80, gui_y, 12, BLACK);
|
||||||
|
|
||||||
gui_y += 45;
|
gui_y += 45;
|
||||||
sprintf(buffer, "Jumps: %u", p_cjump->jumps);
|
sprintf(buffer, "Jumps: %u, %u", p_cjump->jumps, p_cjump->jump_released);
|
||||||
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
DrawText(buffer, gui_x, gui_y, 12, BLACK);
|
||||||
gui_y += 30;
|
gui_y += 30;
|
||||||
sprintf(buffer, "Crouch: %u", p_pstate->is_crouch);
|
sprintf(buffer, "Crouch: %u", p_pstate->is_crouch);
|
||||||
|
|
|
@ -71,12 +71,13 @@ typedef struct _CTileCoord_t {
|
||||||
} CTileCoord_t;
|
} CTileCoord_t;
|
||||||
|
|
||||||
typedef struct _CJump_t {
|
typedef struct _CJump_t {
|
||||||
unsigned int jumps;
|
|
||||||
unsigned int max_jumps;
|
|
||||||
int jump_speed;
|
int jump_speed;
|
||||||
|
uint8_t jumps;
|
||||||
|
uint8_t max_jumps;
|
||||||
bool jumped;
|
bool jumped;
|
||||||
bool jump_ready;
|
bool jump_ready;
|
||||||
bool short_hop;
|
bool short_hop;
|
||||||
|
bool jump_released;
|
||||||
} CJump_t;
|
} CJump_t;
|
||||||
|
|
||||||
typedef enum PlayerState {
|
typedef enum PlayerState {
|
||||||
|
|
|
@ -287,6 +287,7 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
CJump_t* p_cjump = get_component(p_ent, CJUMP_COMP_T);
|
CJump_t* p_cjump = get_component(p_ent, CJUMP_COMP_T);
|
||||||
CPlayerState_t* p_pstate = get_component(p_ent, CPLAYERSTATE_T);
|
CPlayerState_t* p_pstate = get_component(p_ent, CPLAYERSTATE_T);
|
||||||
CMovementState_t* p_mstate = get_component(p_ent, CMOVEMENTSTATE_T);
|
CMovementState_t* p_mstate = get_component(p_ent, CMOVEMENTSTATE_T);
|
||||||
|
CAirTimer_t* p_air = get_component(p_ent, CAIRTIMER_T);
|
||||||
sprintf(buffer, "Pos: %.3f\n %.3f", p_ct->position.x, p_ct->position.y);
|
sprintf(buffer, "Pos: %.3f\n %.3f", p_ct->position.x, p_ct->position.y);
|
||||||
DrawText(buffer, gui_x, 15, 12, BLACK);
|
DrawText(buffer, gui_x, 15, 12, BLACK);
|
||||||
sprintf(buffer, "Vel: %.3f\n %.3f", p_ct->velocity.x, p_ct->velocity.y);
|
sprintf(buffer, "Vel: %.3f\n %.3f", p_ct->velocity.x, p_ct->velocity.y);
|
||||||
|
@ -301,6 +302,13 @@ static void level_scene_render_func(Scene_t* scene)
|
||||||
DrawText(buffer, gui_x, 120, 12, BLACK);
|
DrawText(buffer, gui_x, 120, 12, BLACK);
|
||||||
sprintf(buffer, "Ladder: %u", p_pstate->ladder_state);
|
sprintf(buffer, "Ladder: %u", p_pstate->ladder_state);
|
||||||
DrawText(buffer, gui_x, 150, 12, BLACK);
|
DrawText(buffer, gui_x, 150, 12, BLACK);
|
||||||
|
|
||||||
|
Vector2 air_pos = {data->game_rec.x + data->game_rec.width - 16, data->game_rec.y + data->game_rec.height - 16};
|
||||||
|
for (uint8_t i = 0; i < p_air->curr_count; i++)
|
||||||
|
{
|
||||||
|
DrawCircleV(air_pos, 16, BLUE);
|
||||||
|
air_pos.x -= 32;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//sprintf(buffer, "Spawn Entity: %s", get_spawn_selection_string(current_spawn_selection));
|
//sprintf(buffer, "Spawn Entity: %s", get_spawn_selection_string(current_spawn_selection));
|
||||||
//DrawText(buffer, gui_x, 240, 12, BLACK);
|
//DrawText(buffer, gui_x, 240, 12, BLACK);
|
||||||
|
@ -402,6 +410,7 @@ void init_game_scene(LevelScene_t* scene)
|
||||||
sc_array_add(&scene->scene.systems, &state_transition_update_system);
|
sc_array_add(&scene->scene.systems, &state_transition_update_system);
|
||||||
sc_array_add(&scene->scene.systems, &player_ground_air_transition_system);
|
sc_array_add(&scene->scene.systems, &player_ground_air_transition_system);
|
||||||
sc_array_add(&scene->scene.systems, &lifetimer_update_system);
|
sc_array_add(&scene->scene.systems, &lifetimer_update_system);
|
||||||
|
sc_array_add(&scene->scene.systems, &airtimer_update_system);
|
||||||
sc_array_add(&scene->scene.systems, &container_destroy_system);
|
sc_array_add(&scene->scene.systems, &container_destroy_system);
|
||||||
sc_array_add(&scene->scene.systems, &sprite_animation_system);
|
sc_array_add(&scene->scene.systems, &sprite_animation_system);
|
||||||
sc_array_add(&scene->scene.systems, &camera_update_system);
|
sc_array_add(&scene->scene.systems, &camera_update_system);
|
||||||
|
|
|
@ -337,6 +337,7 @@ void player_movement_input_system(Scene_t* scene)
|
||||||
{
|
{
|
||||||
if (!p_pstate->jump_pressed)
|
if (!p_pstate->jump_pressed)
|
||||||
{
|
{
|
||||||
|
p_cjump->jump_released = true;
|
||||||
if (!p_cjump->short_hop && p_ctransform->velocity.y < 0)
|
if (!p_cjump->short_hop && p_ctransform->velocity.y < 0)
|
||||||
{
|
{
|
||||||
p_cjump->short_hop = true;
|
p_cjump->short_hop = true;
|
||||||
|
@ -359,7 +360,7 @@ void player_movement_input_system(Scene_t* scene)
|
||||||
// Jumps is possible as long as you have a jump
|
// Jumps is possible as long as you have a jump
|
||||||
|
|
||||||
// Check if possible to jump when jump is pressed
|
// Check if possible to jump when jump is pressed
|
||||||
if (p_pstate->jump_pressed && p_cjump->jumps > 0 && p_cjump->jump_ready)
|
if (p_cjump->jump_released && p_pstate->jump_pressed && p_cjump->jumps > 0 && p_cjump->jump_ready)
|
||||||
{
|
{
|
||||||
p_pstate->ladder_state = false;
|
p_pstate->ladder_state = false;
|
||||||
p_cjump->jumps--;
|
p_cjump->jumps--;
|
||||||
|
@ -381,8 +382,8 @@ void player_movement_input_system(Scene_t* scene)
|
||||||
|
|
||||||
p_cjump->jumped = true;
|
p_cjump->jumped = true;
|
||||||
p_cjump->jump_ready = false;
|
p_cjump->jump_ready = false;
|
||||||
|
p_cjump->jump_released = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1225,11 +1226,12 @@ void player_ground_air_transition_system(Scene_t* scene)
|
||||||
// Handle Ground<->Air Transition
|
// Handle Ground<->Air Transition
|
||||||
bool in_water = (p_mstate->water_state & 1);
|
bool in_water = (p_mstate->water_state & 1);
|
||||||
// Landing or in water
|
// Landing or in water
|
||||||
if ((p_mstate->ground_state & 1 || in_water || p_pstate->ladder_state) && !p_pstate->jump_pressed )
|
if ((p_mstate->ground_state & 1 || in_water || p_pstate->ladder_state))
|
||||||
{
|
{
|
||||||
// Recover jumps
|
// Recover jumps
|
||||||
p_cjump->jumps = p_cjump->max_jumps;
|
p_cjump->jumps = p_cjump->max_jumps;
|
||||||
p_cjump->jumped = false;
|
p_cjump->jumped = false;
|
||||||
|
if(!p_cjump->jump_released && !p_pstate->jump_pressed) p_cjump->jump_released = true;
|
||||||
p_cjump->short_hop = false;
|
p_cjump->short_hop = false;
|
||||||
p_cjump->jump_ready = true;
|
p_cjump->jump_ready = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue