From efa0d6fbbd2fd4759df0294ec5121596aeb5636c Mon Sep 17 00:00:00 2001 From: Adam JOLY Date: Mon, 28 Oct 2024 14:41:48 +0100 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=8F=97=EF=B8=8F=E3=80=8D=20wip(D?= =?UTF-8?q?DA):=20Fuck=20that=20was=20hard=20(thx=20@kbz-8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/game/dda.h | 69 +++++--------- includes/game/game.h | 56 +++++------ includes/game/settings.h | 6 +- includes/game/typedef.h | 68 ------------- includes/game/{constant.h => vectwo.h} | 32 +++++-- src/raycasting/dda.c | 105 +++++++++++++++++++++ src/raycasting/dda/dda.c | 38 -------- src/raycasting/dda/dist_dda.c | 36 ------- src/raycasting/dda/get_ray_angle.c | 32 ------- src/raycasting/dda/setup_dda.c | 61 ------------ src/raycasting/dda/while_dda.c | 47 --------- src/raycasting/{dda/line_dda.c => maths.c} | 37 ++++---- 12 files changed, 206 insertions(+), 381 deletions(-) delete mode 100644 includes/game/typedef.h rename includes/game/{constant.h => vectwo.h} (53%) create mode 100644 src/raycasting/dda.c delete mode 100644 src/raycasting/dda/dda.c delete mode 100644 src/raycasting/dda/dist_dda.c delete mode 100644 src/raycasting/dda/get_ray_angle.c delete mode 100644 src/raycasting/dda/setup_dda.c delete mode 100644 src/raycasting/dda/while_dda.c rename src/raycasting/{dda/line_dda.c => maths.c} (56%) diff --git a/includes/game/dda.h b/includes/game/dda.h index 3ff30be..cf5473b 100644 --- a/includes/game/dda.h +++ b/includes/game/dda.h @@ -5,59 +5,38 @@ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/04 14:04:10 by adjoly #+# #+# */ -/* Updated: 2024/10/23 15:00:05 by adjoly ### ########.fr */ +/* Created: 2024/10/28 13:04:36 by adjoly #+# #+# */ +/* Updated: 2024/10/28 14:37:10 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef DDA_H +# ifndef DDA_H # define DDA_H -# include "typedef.h" -# include "settings.h" -# include +# include -/** - * @brief Function used to get all the ray angle - * - * @param player The address of the t_player struct - * @param dda The address of the t_dda struct - */ -void get_ray_angle(t_player *player, t_dda (*dda)[800]); +# include "game.h" +#include "game/vectwo.h" -/** - * @brief Function used to setup all the dda variable prior to casting - * the rays - * - * @param player The address of the t_player struct - * @param dda The address of the t_dda struct - * - */ -void setup_dda(t_dda (*dda)[800], t_player *player); +typedef struct s_dda +{ + bool h; + int i; + t_vec2 map; + t_vec2 vert; + t_vec2 hori; + t_vec2 distance; +} t_dda; -/** - * @brief Function used to cast all the rays - * - * @param dda The address of the t_dda struct - * @param map The map as a char ** - * @param map_coord The coordinate of the player on the map_grid - */ -void while_dda(t_dda (*dda)[800], char **map, t_player *player); +typedef struct s_ray +{ + t_vec2 pos; + float tan; + float angle; + t_vec2 offset; + float distance; +} t_ray; - /// NEED TO COMBINE THOSE IF NOT USEFULL TO SEPARATE -/** - * @brief Function used to get the distance from the player of all rays - * - * @param dda The address of the t_dda struct - */ -float *dist_dda(t_dda dda[WINDOW_X / RAY_SIZE]); +void dda_algo(t_player *play, t_render *render); -/** - * @brief Function used to get the size of the line to be printed on the screen - * - * @param dda The array of the all the distance to the wall of the rays - */ -uint16_t *line_dda(float *wall_dist); - -uint16_t *dda(t_player *player, char **map); #endif diff --git a/includes/game/game.h b/includes/game/game.h index afee3a5..07cf4e8 100644 --- a/includes/game/game.h +++ b/includes/game/game.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/11 16:38:40 by adjoly #+# #+# */ -/* Updated: 2024/10/24 11:38:56 by adjoly ### ########.fr */ +/* Updated: 2024/10/28 14:08:09 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,10 +21,34 @@ # include # include -# include "dda.h" # include "settings.h" -# include "parsing.h" -# include "typedef.h" + +# include "vectwo.h" + +# include "../parsing.h" + +typedef struct s_map +{ + char **arr; + char p_side; + t_coord p_spawnpoint; + t_coord size; +} t_map; + +typedef struct s_render +{ + t_map *world; + void *mlx; + void *win; + void *texture[4]; +} t_render; + +typedef struct s_player +{ + t_vec2 coord; + t_coord map_coords; + double direction; +} t_player; /** * @brief This function is used to handle keypress @@ -36,13 +60,6 @@ */ int key_hook(int key, void *param); -/** - * @brief This function is used to create an image with the player position - * - * @param cub The address of a t_cub struct filled with mlx data and other - * thing - */ -void get_player_image(t_cub *cub); /** * @brief This function is here to change the direction of the player @@ -56,21 +73,4 @@ void get_player_image(t_cub *cub); */ void change_direction(double speed, bool clockwise, t_player *player); -/** - * @brief Function used to draw a square - * - * @param cub The adress of a t_cub struct - * @param coord The coordinate of the printed square - * @param size The size of the printed square - * @param color The color of the printed square - */ -void draw_square(t_cub *cub, t_coord coord, uint16_t size, int color); - -/** - * @brief Function used to draw the map - * - * @param cub The address of the t_cub struct - */ -void print_map(t_cub *cub); - #endif diff --git a/includes/game/settings.h b/includes/game/settings.h index fe2fd5b..c8e9169 100644 --- a/includes/game/settings.h +++ b/includes/game/settings.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/04 14:06:39 by adjoly #+# #+# */ -/* Updated: 2024/10/23 11:18:38 by adjoly ### ########.fr */ +/* Updated: 2024/10/28 14:04:25 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,11 +21,13 @@ # define D_KEY 7 # define WHITE 0xFFFFFFFF +# define DEG_TO_RAD 0.0174533 + # define WINDOW_Y 900 # define WINDOW_X 1600 # define PLAYER_ROT_SPEED (2 * M_PI) / 128 # define PLAYER_SPEED 3 -# define MAP_CHUNK_SIZE 64 +# define CHUNK_SIZE 64 # define RAY_SIZE 2 # define FOV ( 60 * (M_PI / 180) ) diff --git a/includes/game/typedef.h b/includes/game/typedef.h deleted file mode 100644 index 4e56264..0000000 --- a/includes/game/typedef.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* typedef.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/04 14:28:24 by adjoly #+# #+# */ -/* Updated: 2024/10/23 14:33:33 by adjoly ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef STRUCT_H -# define STRUCT_H - -# include -# include "parsing.h" - -/** - * @brief Enum for the wall side that has been hit - */ -typedef enum s_wall_side -{ - HORIZONTAL, - VERTICAL -} t_wall_side; - -typedef struct s_coord_f -{ - float x; - float y; -} t_coord_f; - -typedef struct s_step -{ - char x; - char y; -} t_step; - -typedef struct s_player -{ - t_coord coords; - t_coord map_coords; - double direction; -} t_player; - -typedef struct s_cub -{ - void *mlx; - void *win; - void *sprites; - void *img; - char **map; - t_player player; -} t_cub; - - -typedef struct s_dda -{ - t_coord_f ray_dir; - t_coord_f side_dist; - t_coord_f delta_dist; - t_step step; - t_wall_side wall_side; - bool wall_hit; -} t_dda; - -#endif diff --git a/includes/game/constant.h b/includes/game/vectwo.h similarity index 53% rename from includes/game/constant.h rename to includes/game/vectwo.h index 25bf300..1fd0715 100644 --- a/includes/game/constant.h +++ b/includes/game/vectwo.h @@ -1,18 +1,38 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* constant.h :+: :+: :+: */ +/* vectwo.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/04 16:39:48 by adjoly #+# #+# */ -/* Updated: 2024/10/04 16:40:10 by adjoly ### ########.fr */ +/* Created: 2024/10/28 13:32:14 by adjoly #+# #+# */ +/* Updated: 2024/10/28 14:24:56 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef CONSTANT_H -# define CONSTANT_H +#ifndef VECTWO_H +# define VECTWO_H -# define WHITE 0xFFFFFFFF +typedef struct s_vec2 +{ + float x; + float y; +} t_vec2; +/* ------------------ Vec2 Utils ------------------ */ + +/** + * @brief Gives you the distance between two point + */ +float vec2_dist(t_vec2 first, t_vec2 second); + +/** + * @brief Just add second to first + */ +void vec2_add(t_vec2 *first, t_vec2 second); + +/** + * @brief Just substract second to first + */ +void vec2_sub(t_vec2 *first, t_vec2 second); #endif diff --git a/src/raycasting/dda.c b/src/raycasting/dda.c new file mode 100644 index 0000000..1d13f69 --- /dev/null +++ b/src/raycasting/dda.c @@ -0,0 +1,105 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* dda.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/07 16:55:09 by adjoly #+# #+# */ +/* Updated: 2024/10/28 14:40:14 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "game/vectwo.h" +#include +#include +#include + +void setup_dda_hor(t_player *play, t_ray *ray, t_dda *dda) +{ + dda->h = true; + ray->tan = tan(ray->angle); + if (cos(ray->angle) < -0.001) + { + ray->pos.x = (((int)play->coord.x >> 6) << 6) - 0.001; + ray->pos.y -= (play->coord.x - ray->pos.x) * ray->tan + play->coord.y; + ray->offset.x = -CHUNK_SIZE; + ray->offset.y = -ray->offset.x * ray->tan; + } + else if(cos(ray->angle) > 0.001) + { + ray->pos.x = (((int)play->coord.x >> 6) << 6) + CHUNK_SIZE; + ray->pos.y -= (play->coord.x - ray->pos.x) * ray->tan + play->coord.y; + ray->offset.x = CHUNK_SIZE; + ray->offset.y = -ray->offset.x * ray->tan; + } +} + +void setup_dda_ver(t_player *play, t_ray *ray, t_dda *dda) +{ + dda->h = false; + ray->tan = 1 / tan(ray->angle); + if (sin(ray->angle) < -0.001) + { + ray->pos.y = (((int)play->coord.y >> 6) << 6) - 0.001; + ray->pos.x = (play->coord.y - ray->pos.y) * ray->tan + play->coord.x; + ray->offset.y = -CHUNK_SIZE; + ray->offset.x = -ray->offset.y * ray->tan; + } + else if(sin(ray->angle) > 0.001) + { + ray->pos.y = (((int)play->coord.y >> 6) << 6) + CHUNK_SIZE; + ray->pos.x -= (play->coord.y - ray->pos.y) * ray->tan + play->coord.x; + ray->offset.y = CHUNK_SIZE; + ray->offset.x = -ray->offset.y * ray->tan; + } +} + +void dda_loop(t_dda *dda, t_ray *ray, t_map *map, t_player *play) +{ + uint16_t w; + uint16_t h; + + w = map->size.x; + h = map->size.y; + while (dda->i) + { + dda->map.x = ((int)ray->pos.x >> 6); + dda->map.y = ((int)ray->pos.x >> 6); + if (dda->map.x >= 0 && dda->map.x < w && dda->map.y >= 0 && dda->map.y < h && \ + map->arr[(int)dda->map.y][(int)dda->map.x] == '1') + { + dda->i = 0; + if (dda->h) + dda->distance.x = vec2_dist(play->coord, ray->pos); + } + else + { + vec2_add(&ray->pos, ray->offset); + dda->i--; + } + } +} + +void dda(t_player *player, t_render *render) +{ + t_dda dda; + t_ray ray; + + setup_dda_hor(player, &ray, &dda); + dda_loop(&dda, &ray, render->world, player); + setup_dda_ver(player, &ray, &dda); + dda_loop(&dda, &ray, render->world, player); + if (dda.distance.x < dda.distance.y) + { + ray.pos.x = fabsf(dda.hori.x); + ray.pos.y = fabsf(dda.hori.y); + ray.distance = dda.distance.x; + } + else + { + ray.pos.x = fabsf(dda.vert.x); + ray.pos.y = fabsf(dda.vert.y); + ray.distance = dda.distance.y; + } +} diff --git a/src/raycasting/dda/dda.c b/src/raycasting/dda/dda.c deleted file mode 100644 index 0667d8a..0000000 --- a/src/raycasting/dda/dda.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* dda.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/07 16:55:09 by adjoly #+# #+# */ -/* Updated: 2024/10/23 15:04:45 by adjoly ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "game/dda.h" -#include "game/settings.h" -#include "sys/types.h" -#include -#include - -uint16_t *dda(t_player *player, char **map) -{ - t_dda dda[WINDOW_X / RAY_SIZE]; - float *wall_dist; - uint16_t *line_size; - - setup_dda(&dda, player); - player->map_coords.x = player->coords.x - player->coords.x % MAP_CHUNK_SIZE; - player->map_coords.y = player->coords.y - player->coords.y % MAP_CHUNK_SIZE; - while_dda(&dda, map, player); - wall_dist = dist_dda(dda); - line_size = line_dda(wall_dist); - return (line_size); -} - -/** -* calculate size on screen -* screen_height / per_wall_dist -* (and get orientation) -*/ diff --git a/src/raycasting/dda/dist_dda.c b/src/raycasting/dda/dist_dda.c deleted file mode 100644 index 0abfa19..0000000 --- a/src/raycasting/dda/dist_dda.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* dist_dda.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/08 13:26:19 by adjoly #+# #+# */ -/* Updated: 2024/10/23 14:10:52 by adjoly ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "game/dda.h" -#include -#include "game/settings.h" -#include "libft.h" - -float *dist_dda(t_dda dda[WINDOW_X / RAY_SIZE]) -{ - size_t i; - float *wall_dist; - - i = 0; - wall_dist = ft_calloc(WINDOW_X / RAY_SIZE + 1, sizeof(float)); - if (!wall_dist) - return (NULL); - while (i < WINDOW_X / RAY_SIZE) - { - if (dda[i].wall_side == HORIZONTAL) - wall_dist[i] = dda[i].side_dist.x - dda[i].delta_dist.x; - else - wall_dist[i] = dda[i].side_dist.y - dda[i].delta_dist.y; - i++; - } - return (wall_dist); -} diff --git a/src/raycasting/dda/get_ray_angle.c b/src/raycasting/dda/get_ray_angle.c deleted file mode 100644 index f2d7509..0000000 --- a/src/raycasting/dda/get_ray_angle.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* get_ray_angle.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/09/29 15:26:29 by adjoly #+# #+# */ -/* Updated: 2024/10/23 14:19:21 by adjoly ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "game/dda.h" -#include "game/settings.h" -#include -#include -#include - -void get_ray_angle(t_player *player, t_dda (*dda)[WINDOW_X / RAY_SIZE]) -{ - uint16_t x; - float ray_angle; - - x = 0; - while (x < WINDOW_X) - { - ray_angle = (float)(player->direction - (FOV / 2) + ((float)x / WINDOW_X) * FOV); - (*dda)[x / RAY_SIZE].ray_dir.x = cos(ray_angle); - (*dda)[x / RAY_SIZE].ray_dir.y = sin(ray_angle); - x += RAY_SIZE; - } -} diff --git a/src/raycasting/dda/setup_dda.c b/src/raycasting/dda/setup_dda.c deleted file mode 100644 index 5c6467e..0000000 --- a/src/raycasting/dda/setup_dda.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* setup_dda.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/09/30 23:47:14 by adjoly #+# #+# */ -/* Updated: 2024/10/24 12:40:00 by adjoly ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "game/settings.h" -#include "game/dda.h" -#include -#include -#include -#include - -void get_side_dist(t_dda *dda, t_player *player) -{ - if (dda->ray_dir.x < 0) - { - dda->side_dist.x = (player->coords.x - player->map_coords.x) * dda->delta_dist.x; - dda->step.x = -MAP_CHUNK_SIZE; - } - else - { - dda->side_dist.x = ((player->map_coords.x + MAP_CHUNK_SIZE) - player->coords.x) * dda->delta_dist.x; - dda->step.x = MAP_CHUNK_SIZE; - } - if (dda->ray_dir.y < 0) - { - dda->side_dist.y = (player->coords.y - player->map_coords.y) * dda->delta_dist.y; - dda->step.y = -MAP_CHUNK_SIZE; - } - else - { - dda->side_dist.y = (player->map_coords.y + MAP_CHUNK_SIZE - player->coords.y) * dda->delta_dist.y; - dda->step.y = MAP_CHUNK_SIZE; - } -} - -void setup_dda(t_dda (*dda)[WINDOW_X / RAY_SIZE], t_player *player) -{ - size_t i; - - i = 0; - get_ray_angle(player, dda); - while (i < WINDOW_X / RAY_SIZE) - { - (*dda)[i].delta_dist.x = fabsf(MAP_CHUNK_SIZE / (*dda)[i].ray_dir.x); - (*dda)[i].delta_dist.y = fabsf(MAP_CHUNK_SIZE / (*dda)[i].ray_dir.y); - printf("%f \n", (*dda)[i].delta_dist.x); - printf("%f \n", (*dda)[i].delta_dist.y); - get_side_dist(&(*dda)[i], player); - printf("side %f \n", (*dda)[i].side_dist.x); - printf("side %f \n", (*dda)[i].side_dist.y); - i++; - } -} diff --git a/src/raycasting/dda/while_dda.c b/src/raycasting/dda/while_dda.c deleted file mode 100644 index 381d60e..0000000 --- a/src/raycasting/dda/while_dda.c +++ /dev/null @@ -1,47 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* while_dda.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/06 18:46:56 by adjoly #+# #+# */ -/* Updated: 2024/10/23 15:03:03 by adjoly ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "game/dda.h" -#include "game/settings.h" -#include - -void while_dda(t_dda (*dda)[WINDOW_X / RAY_SIZE], char **map, t_player *player) -{ - uint16_t i; - t_coord map_coord; - - i = 0; - while (i < WINDOW_X / RAY_SIZE) - { - (*dda)[i].wall_hit = false; - map_coord.x = player->map_coords.x; - map_coord.y = player->map_coords.y; - while (!(*dda)[i].wall_hit) - { - if ((*dda)[i].side_dist.x < (*dda)[i].side_dist.y) - { - (*dda)[i].side_dist.x += (*dda)[i].delta_dist.x; - map_coord.x += (*dda)[i].step.x; - (*dda)[i].wall_side = HORIZONTAL; - } - else - { - (*dda)[i].side_dist.y += (*dda)[i].delta_dist.y; - map_coord.y += (*dda)[i].step.y; - (*dda)[i].wall_side = VERTICAL; - } - if (map_coord.x < 0 || map_coord.y < 0 || map[map_coord.x / MAP_CHUNK_SIZE][map_coord.y / MAP_CHUNK_SIZE] == '1') - (*dda)[i].wall_hit = true; - } - i++; - } -} diff --git a/src/raycasting/dda/line_dda.c b/src/raycasting/maths.c similarity index 56% rename from src/raycasting/dda/line_dda.c rename to src/raycasting/maths.c index 76afae6..3d5917c 100644 --- a/src/raycasting/dda/line_dda.c +++ b/src/raycasting/maths.c @@ -1,30 +1,31 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* line_dda.c :+: :+: :+: */ +/* maths.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2024/10/13 17:27:44 by adjoly #+# #+# */ -/* Updated: 2024/10/22 13:03:40 by adjoly ### ########.fr */ +/* Created: 2024/10/26 15:47:29 by adjoly #+# #+# */ +/* Updated: 2024/10/28 14:00:34 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ -#include "game/settings.h" -#include "game/dda.h" -#include +#include +#include -uint16_t *line_dda(float *wall_dist) +float vec2_dist(t_vec2 first, t_vec2 second) { - uint16_t i; - uint16_t *line_size; - - i = 0; - line_size = malloc(WINDOW_X / RAY_SIZE * sizeof(uint16_t)); - while (i < WINDOW_X / RAY_SIZE) - { - line_size[i] = WINDOW_Y * MAP_CHUNK_SIZE / wall_dist[i]; - i++; - } - return (line_size); + return (sqrt(powf(second.x - first.x, 2) + powf(second.y - first.y, 2))); +} + +void vec2_add(t_vec2 *first, t_vec2 second) +{ + first->x += second.x; + first->y += second.y; +} + +void vec2_sub(t_vec2 *first, t_vec2 second) +{ + first->x -= second.x; + first->y -= second.y; }