Skip to content

Commit

Permalink
GLIDING WORKSKSS?!??!?!?!? (kinda)
Browse files Browse the repository at this point in the history
Can get kinda "in" the wall.
  • Loading branch information
joppe committed Jan 19, 2024
1 parent 34688bd commit cb3d7df
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/game/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: yzaim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/08 15:27:23 by yzaim #+# #+# */
/* Updated: 2024/01/20 00:22:42 by joppe ######## odam.nl */
/* Updated: 2024/01/20 00:39:14 by joppe ######## odam.nl */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -36,7 +36,6 @@ void print_angle(t_player *p)
{
// NORTH = 0
const float angle = (atan2(p->direction.x, p->direction.y) / PI * 180 + 180);

if (angle > 45.0 && angle < 135.0)
{
printf("N\n");
Expand Down Expand Up @@ -64,6 +63,24 @@ void player_move(t_player *p, t_vec2d transform)
p->position.y += transform.y;
p->position.x += transform.x;
}
else
{
const int comp = (r.hit_side == SIDE_N || r.hit_side == SIDE_S);
const t_vec2d normal = {comp, !comp};
const double dot_product = vec2d_dot_product(transform, normal);

t_vec2d delta_pos;
delta_pos.x = transform.x - normal.x * dot_product;
delta_pos.y = transform.y - normal.y * dot_product;
r = raycaster_cast(p->position, vec2d_normalize(transform), bound_check, p->meta);

if (r.length > .3)
{
p->position.x += delta_pos.x;
p->position.y += delta_pos.y;
}

}
print_angle(p);
player_raycast(p);
}
Expand Down

0 comments on commit cb3d7df

Please sign in to comment.