diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_collision.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ft_collision.c b/src/ft_collision.c index 385b2f7..6468433 100644 --- a/src/ft_collision.c +++ b/src/ft_collision.c @@ -95,3 +95,33 @@ int } return (0); } + +int8_t + ft_bb_collision(double old_y, double old_x, t_sprite *sl, t_map *ml) +{ + if (sl->r == 0 && !ft_ischarset("0e", + ml->map[(uint64_t)(sl->s_pos_y + 1.5)][(uint64_t)old_x])) + { + sl->s_pos_y = old_y; + return (1); + } + else if (sl->r == 1 && !ft_ischarset("0e", + ml->map[(uint64_t)(sl->s_pos_y - 0.5)][(uint64_t)old_x])) + { + sl->s_pos_y = old_y; + return (1); + } + else if (sl->r == 2 && !ft_ischarset("0e", + ml->map[(uint64_t)old_y][(uint64_t)(sl->s_pos_x - 0.5)])) + { + sl->s_pos_x = old_x; + return (1); + } + else if (sl->r == 3 && !ft_ischarset("0e", + ml->map[(uint64_t)old_y][(uint64_t)(sl->s_pos_x + 1.5)])) + { + sl->s_pos_x = old_x; + return (1); + } + return (0); +} |