Allow jumping in one tile gaps
Changelog: - With the change in bbox shifting, jumping in gaps is possiblescene_man
parent
8606b595ab
commit
68e8f7bf1c
|
@ -212,34 +212,18 @@ void player_movement_input_system(Scene_t* scene)
|
||||||
// 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->cooldown_timer == 0)
|
if (p_pstate->jump_pressed && p_cjump->jumps > 0 && p_cjump->cooldown_timer == 0)
|
||||||
{
|
{
|
||||||
bool jump_valid = true;
|
p_cjump->jumps--;
|
||||||
|
if (!in_water)
|
||||||
// Check Jump from crouch
|
|
||||||
if(p_pstate->is_crouch & 1)
|
|
||||||
{
|
{
|
||||||
Vector2 test_pos = p_ctransform->position;
|
p_ctransform->velocity.y -= p_cjump->jump_speed;
|
||||||
Vector2 test_bbox = {PLAYER_WIDTH, PLAYER_HEIGHT};
|
}
|
||||||
Vector2 top = {0, -1};
|
else
|
||||||
test_pos.x += PLAYER_C_XOFFSET;
|
{
|
||||||
test_pos.y -= PLAYER_C_YOFFSET;
|
p_ctransform->velocity.y -= p_cjump->jump_speed / 1.75;
|
||||||
jump_valid = !check_collision_at(test_pos, test_bbox, &tilemap, top, &scene->ent_manager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jump okay
|
p_cjump->jumped = true;
|
||||||
if (jump_valid)
|
p_cjump->cooldown_timer = 15;
|
||||||
{
|
|
||||||
if (!in_water)
|
|
||||||
{
|
|
||||||
p_ctransform->velocity.y -= p_cjump->jump_speed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p_ctransform->velocity.y -= p_cjump->jump_speed / 1.75;
|
|
||||||
}
|
|
||||||
|
|
||||||
p_cjump->jumped = true;
|
|
||||||
p_cjump->cooldown_timer = 15;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue