diff options
Diffstat (limited to 'src/engine/entity.c')
-rw-r--r-- | src/engine/entity.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/engine/entity.c b/src/engine/entity.c index b374f8c..58b62c9 100644 --- a/src/engine/entity.c +++ b/src/engine/entity.c @@ -50,13 +50,13 @@ hh_entity hh_background_collision (hh_entity temp_old_entity,hh_entity temp_new_ // solves x collision if (temp_old_entity.vel.x <= 0) { if (hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 0, .y=temp_old_entity.pos.y + 0})) || - hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 0, .y=temp_old_entity.pos.y + 15}))) { + hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 0, .y=temp_old_entity.pos.y + (temp_old_entity.size.y-1)}))) { temp_new_entity.pos.x = (temp_new_entity.pos.x & ~15) + 16, temp_new_entity.vel.x = 0; } } else { - if (hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 16, .y=temp_old_entity.pos.y + 0})) || - hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 16, .y=temp_old_entity.pos.y + 15}))) { + if (hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + temp_old_entity.size.x, .y=temp_old_entity.pos.y + 0})) || + hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + temp_old_entity.size.x, .y=temp_old_entity.pos.y + (temp_old_entity.size.y-1)}))) { temp_new_entity.pos.x = temp_new_entity.pos.x & ~15, // <-- magic comma, NOT TOUCHY temp_new_entity.vel.x = 0; } @@ -65,13 +65,13 @@ hh_entity hh_background_collision (hh_entity temp_old_entity,hh_entity temp_new_ //solves y collision if (temp_old_entity.vel.y <= 0) { if (hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 0, .y=temp_new_entity.pos.y + 0})) || - hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 15, .y=temp_new_entity.pos.y + 0}))) { + hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + (temp_new_entity.size.x-1), .y=temp_new_entity.pos.y + 0}))) { temp_new_entity.pos.y = (temp_new_entity.pos.y & ~15) + 16, temp_new_entity.vel.y = 0; } } else { - if (hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 0, .y=temp_new_entity.pos.y + 15})) || - hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 15, .y=temp_new_entity.pos.y + 15}))) { + if (hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + 0, .y=temp_new_entity.pos.y + (temp_new_entity.size.y-1)})) || + hh_colidable(hh_world_to_tile((vec2){.x=temp_new_entity.pos.x + (temp_new_entity.size.x-1), .y=temp_new_entity.pos.y + (temp_new_entity.size.y-1)}))) { temp_new_entity.pos.y = temp_new_entity.pos.y & ~15, temp_new_entity.vel.y = 0; temp_new_entity.is_grounded = true; |