42_so_long/src/utils/point1.c
mcolonna 9e81a59a7e feat: loots of things!!! *
Added features:
- Check if the room is valid
- Pathfinding
- Firsk
- Camera
Changes:
- Borders
Dev:
- new test rooms
- ber.vim plugin
2024-04-15 19:46:35 +02:00

53 lines
1.5 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* point.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/15 15:24:37 by mcolonna #+# #+# */
/* Updated: 2024/04/11 17:25:55 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes.h"
t_point point_init(int x, int y)
{
const t_point r = {x, y};
return (r);
}
t_point point_add(t_point point, int x)
{
point.x += x;
point.y += x;
return (point);
}
void point_addto(t_point *dest, t_point src)
{
dest->x += src.x;
dest->y += src.y;
}
t_point point_fromdirection(t_direction direction)
{
if (direction == LEFT)
return (point_init(-1, 0));
if (direction == RIGHT)
return (point_init(+1, 0));
if (direction == UP)
return (point_init(0, -1));
if (direction == DOWN)
return (point_init(0, +1));
return (point_init(0, 0));
}
t_point point_multiply(t_point point, int x)
{
point.x *= x;
point.y *= x;
return (point);
}