Compare commits

..

No commits in common. "5b29ad4ba45124c6ed0769dc0c306106031431e4" and "c02eba9548452fe13f51bdc962d6e42238935242" have entirely different histories.

1 changed files with 28 additions and 41 deletions

View File

@ -15,8 +15,6 @@
#include "constants.h" #include "constants.h"
#include <stdio.h> #include <stdio.h>
#define CRITICAL_WATER_OVERLAP 0.4f
void simple_particle_system_update(Particle_t* part, void* user_data, float delta_time); void simple_particle_system_update(Particle_t* part, void* user_data, float delta_time);
void floating_particle_system_update(Particle_t* part, void* user_data, float delta_time); void floating_particle_system_update(Particle_t* part, void* user_data, float delta_time);
bool check_in_water(const ParticleEmitter_t* emitter, float delta_time); bool check_in_water(const ParticleEmitter_t* emitter, float delta_time);
@ -423,7 +421,7 @@ void player_movement_input_system(Scene_t* scene)
if (!(p_mstate->ground_state & 1)) p_pstate->is_crouch &= 0b01; if (!(p_mstate->ground_state & 1)) p_pstate->is_crouch &= 0b01;
} }
if (p_mstate->water_overlap < CRITICAL_WATER_OVERLAP) if (!in_water)
{ {
p_pstate->player_dir.y = 0; p_pstate->player_dir.y = 0;
} }
@ -432,9 +430,8 @@ void player_movement_input_system(Scene_t* scene)
{ {
// Although this can be achieved via higher friction, i'll explain away as the player is not // Although this can be achieved via higher friction, i'll explain away as the player is not
// good with swimming, resulting in lower movement acceleration // good with swimming, resulting in lower movement acceleration
p_ctransform->accel = Vector2Scale(Vector2Normalize(p_pstate->player_dir), MOVE_ACCEL / (1.0f + 0.2f * p_mstate->water_overlap)); p_ctransform->accel = Vector2Scale(Vector2Normalize(p_pstate->player_dir), MOVE_ACCEL / (in_water ? 1.2f : 1.0f));
p_ctransform->accel.y *= p_mstate->water_overlap * 0.8;
if (p_pstate->is_crouch & 1) if (p_pstate->is_crouch & 1)
{ {
p_ctransform->accel = Vector2Scale(p_ctransform->accel, 0.5); p_ctransform->accel = Vector2Scale(p_ctransform->accel, 0.5);
@ -480,11 +477,7 @@ void player_movement_input_system(Scene_t* scene)
} }
else else
{ {
p_ctransform->velocity.y = -p_cjump->jump_speed p_ctransform->velocity.y = -p_cjump->jump_speed / 1.75;
/ (
(p_mstate->ground_state & 1) ? 1 : 1.2
+ (p_mstate->water_overlap > CRITICAL_WATER_OVERLAP ? 0.6 * p_mstate->water_overlap : 0)
);
} }
p_pstate->ladder_state = false; p_pstate->ladder_state = false;
@ -553,11 +546,16 @@ void player_bbox_update_system(Scene_t* scene)
} }
} }
Vector2 point_to_check = Vector2Add(p_player->position, offset);
// As long as the change in hitbox is less than a tile size, if (
// it should be fine check_collision_at(
p_player, point_to_check, new_bbox, &tilemap
) != 1
)
{
set_bbox(p_bbox, new_bbox.x, new_bbox.y); set_bbox(p_bbox, new_bbox.x, new_bbox.y);
p_player->position = Vector2Add(p_player->position, offset); p_player->position = Vector2Add(p_player->position, offset);
}
CHitBoxes_t* p_hitbox = get_component(p_player, CHITBOXES_T); CHitBoxes_t* p_hitbox = get_component(p_player, CHITBOXES_T);
p_hitbox->boxes[0].height = p_bbox->size.y + 4; p_hitbox->boxes[0].height = p_bbox->size.y + 4;
@ -566,33 +564,22 @@ void player_bbox_update_system(Scene_t* scene)
if ((p_mstate->water_state & 1) && !(p_mstate->ground_state & 1)) if ((p_mstate->water_state & 1) && !(p_mstate->ground_state & 1))
{ {
#define EXTENDED_WIDTH_FACTOR 1.5f;
float extended_width = p_bbox->size.x * EXTENDED_WIDTH_FACTOR;
p_hurtbox->size = p_bbox->size; p_hurtbox->size = p_bbox->size;
p_hurtbox->size.x *= EXTENDED_WIDTH_FACTOR; p_hurtbox->size.x *= 1.7;
p_hitbox->boxes[0].width = extended_width; p_hitbox->boxes[0].width = p_bbox->size.x * 2.0f;
p_hitbox->boxes[1].width = extended_width + 4; p_hitbox->boxes[1].width = p_bbox->size.x * 2.0f + 4;
if (p_mstate->x_dir > 0)
AnchorPoint_t anchor = p_mstate->x_dir > 0 ? AP_TOP_RIGHT : AP_TOP_LEFT; {
Vector2 offset = shift_bbox( p_hitbox->boxes[0].x = -p_bbox->size.x;
p_bbox->size, p_hitbox->boxes[1].x = -p_bbox->size.x - 2;
(Vector2){ p_hurtbox->offset.x = -p_bbox->size.x * 0.7;
p_hitbox->boxes[0].width, p_hitbox->boxes[0].height }
}, else
anchor {
); p_hitbox->boxes[0].x = 0;
p_hitbox->boxes[0].x = offset.x; p_hitbox->boxes[1].x = -2;
p_hurtbox->offset.x = 0;
offset = shift_bbox( }
p_bbox->size,
(Vector2){
p_hitbox->boxes[1].width, p_hitbox->boxes[1].height
},
anchor
);
p_hitbox->boxes[1].x = offset.x;
p_hurtbox->offset = shift_bbox(p_bbox->size, p_hurtbox->size, anchor);
} }
else else
{ {