premiere tentative qui ne rend pas la bon carre autour du tetraminos

This commit is contained in:
Hugo LAMY
2019-04-14 17:31:36 +02:00
parent ea6595fbd6
commit 94fcafd8d6
4 changed files with 71 additions and 2 deletions

BIN
includes/.fillit.h.swp Normal file

Binary file not shown.

View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
/* Updated: 2019/04/14 14:31:26 by vmanzoni ### ########.fr */
/* Updated: 2019/04/14 16:32:21 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -36,4 +36,13 @@ char *read_file(char *file);
void print_error(char *s, int fd);
int ft_file_errors(char *file);
typedef struct s_fillist
{
int id;
char **tetraminos;
int position[2];
int size[2];
struct s_fillist *next;
} t_fillist;
#endif

60
srcs/add_to_list.c Normal file
View File

@@ -0,0 +1,60 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* add_to_list.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
/* Updated: 2019/04/14 17:30:57 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/fillit.h"
#include <stdio.h>
void find_start_to_end(char **square, int *x1, int *x2, int *y1, int *y2)
{
while (*y1 == 4 && !(*y1 = 0) && square[++(*x1)][0] != '#')
while (*y1 < 4 && square[*x1][*y1] != '#')
(*y1)++;
while (*y2 == 0 && (*y2 = 3) && square[--(*x2)][3] != '#')
while (*y2 > 0 && square[*x2][*y2] != '#')
(*y2)--;
}
void reduce_tetraminos(char **square, t_fillist *list)
{
int x1;
int x2;
int y1;
int y2;
x1 = -1;
x2 = 4;
y1 = 4;
y2 = 0;
find_start_to_end(square, &x1, &x2, &y1, &y2);
printf("de [%d,%d] a [%d,%d]\n",x1, y1, x2, y2);
}
int add_to_list(char **square)
{
t_fillist *list;
square++;
printf("square[0] : %s\n", square[0]);
if (!(list = (t_fillist*)malloc(sizeof(*list))))
return (0);
reduce_tetraminos(square, list);
return (0);
}
int main(int ac, char **av)
{
if (ac == 5)
{
add_to_list(av);
}
return (0);
}

View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
/* Updated: 2019/04/14 14:39:28 by vmanzoni ### ########.fr */
/* Updated: 2019/04/14 15:18:46 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */