Compare commits

..

No commits in common. "5ddb9f00cae6e179e45c06420be34b86c8b295db" and "87b2db4ea4e9e4600fe1e3a7ec5c2683f72e0ed3" have entirely different histories.

1 changed files with 23 additions and 28 deletions

View File

@ -232,6 +232,25 @@ void player_movement_input_system(Scene_t* scene)
} }
// Friction
if (in_water)
{
// Apply water friction
// Consistent in all direction
p_ctransform->accel = Vector2Add(
p_ctransform->accel,
Vector2Scale(p_ctransform->velocity, -5.5)
);
}
else
{
// For game feel, y is set to air resistance only
// x is set to ground resistance (even in air)
// If not, then player is can go faster by bunny hopping
// which is fun but not quite beneficial here
p_ctransform->accel.x += p_ctransform->velocity.x * -3.3;
p_ctransform->accel.y += p_ctransform->velocity.y * -1;
}
p_pstate->player_dir.x = 0; p_pstate->player_dir.x = 0;
p_pstate->player_dir.y = 0; p_pstate->player_dir.y = 0;
} }
@ -462,14 +481,7 @@ void tile_collision_system(Scene_t *scene)
CTransform_t *p_other_ct = get_component(&scene->ent_manager, p_other_ent, CTRANSFORM_COMP_T); CTransform_t *p_other_ct = get_component(&scene->ent_manager, p_other_ent, CTRANSFORM_COMP_T);
if (p_ctransform->position.y + p_bbox->size.y <= p_other_ct->position.y) if (p_ctransform->position.y + p_bbox->size.y <= p_other_ct->position.y)
{ {
p_ctransform->velocity.y = -400; p_ctransform->velocity.y = (p_pstate->jump_pressed)? -600 : -400;
if (p_pstate->jump_pressed)
{
p_ctransform->velocity.y = -600;
CJump_t * p_cjump = get_component(&scene->ent_manager, p_ent, CJUMP_COMP_T);
p_cjump->short_hop = false;
p_cjump->jumped = true;
}
} }
remove_entity(&scene->ent_manager, other_ent_idx); remove_entity(&scene->ent_manager, other_ent_idx);
} }
@ -547,25 +559,6 @@ void global_external_forces_system(Scene_t *scene)
} }
p_ctransform->accel = Vector2Add(p_ctransform->accel, GRAVITY); p_ctransform->accel = Vector2Add(p_ctransform->accel, GRAVITY);
} }
// Friction
if (p_mstate->water_state & 1)
{
// Apply water friction
// Consistent in all direction
p_ctransform->accel = Vector2Add(
p_ctransform->accel,
Vector2Scale(p_ctransform->velocity, -5.5)
);
}
else
{
// For game feel, y is set to air resistance only
// x is set to ground resistance (even in air)
// If not, then player is can go faster by bunny hopping
// which is fun but not quite beneficial here
p_ctransform->accel.x += p_ctransform->velocity.x * -3.3;
p_ctransform->accel.y += p_ctransform->velocity.y * -1;
}
} }
} }
@ -621,7 +614,9 @@ void player_ground_air_transition_system(Scene_t* scene)
if (!in_water) if (!in_water)
p_cjump->cooldown_timer = 0; p_cjump->cooldown_timer = 0;
} }
else if (p_mstate->water_state == 0b10 || p_mstate->ground_state == 0b10)
// TODO: Handle in water <-> out of water transition
if (p_mstate->water_state == 0b10 || p_mstate->ground_state == 0b10)
{ {
p_cjump->jumps -= (p_cjump->jumps > 0)? 1:0; p_cjump->jumps -= (p_cjump->jumps > 0)? 1:0;
} }