From 3c02068ca68729b0e9891104c0b3e779b6fbf3c2 Mon Sep 17 00:00:00 2001 From: En Yi Date: Tue, 3 Jan 2023 22:41:54 +0800 Subject: [PATCH] Fix jump not decremented in air Changelog: - Remove jumps when transition from ground to air as well - Use half size at approriate places --- scene_impl.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scene_impl.c b/scene_impl.c index 794c82d..44ea9af 100644 --- a/scene_impl.c +++ b/scene_impl.c @@ -317,7 +317,6 @@ static void player_movement_input_system(Scene_t* scene) } p_cjump->jumped = true; - p_cjump->jumps--; p_cjump->cooldown_timer = 15; } } @@ -439,8 +438,8 @@ static void movement_update_system(Scene_t* scene) if (p_ctransform->water_state & 1) { unsigned int tile_idx = get_tile_idx( - p_ctransform->position.x + p_bbox->size.x / 2, - p_ctransform->position.y + p_bbox->size.y / 2, + p_ctransform->position.x + p_bbox->half_size.x, + p_ctransform->position.y + p_bbox->half_size.y, data->tilemap.width ); @@ -499,7 +498,7 @@ static void player_ground_air_transition_system(Scene_t* scene) } // TODO: Handle in water <-> out of water transition - if (p_ctransform->water_state == 0b10) + if (p_ctransform->water_state == 0b10 || p_ctransform->ground_state == 0b10) { p_cjump->jumps -= (p_cjump->jumps > 0)? 1:0; } @@ -632,8 +631,8 @@ static void state_transition_update_system(Scene_t *scene) if (!(p_ctransform->water_state & 1)) { unsigned int tile_idx = get_tile_idx( - p_ctransform->position.x + p_bbox->size.x / 2, - p_ctransform->position.y + p_bbox->size.y / 2, + p_ctransform->position.x + p_bbox->half_size.x, + p_ctransform->position.y + p_bbox->half_size.y, data->tilemap.width );