91 lines
2.4 KiB
C
91 lines
2.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* fillit.h :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2016/12/14 16:42:06 by gtertysh #+# #+# */
|
|
/* Updated: 2016/12/20 19:18:00 by gtertysh ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#ifndef FILLIT_H
|
|
# define FILLIT_H
|
|
|
|
#include "libft.h"
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <fcntl.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h> // warning!
|
|
|
|
# define BUF_S 8192
|
|
# define HOW_MUCH 10000
|
|
|
|
typedef struct s_coord
|
|
{
|
|
int x;
|
|
int y;
|
|
} t_coord;
|
|
|
|
typedef struct s_ttrmn
|
|
{
|
|
char t[17];
|
|
int x;
|
|
int y;
|
|
t_coord c[4];
|
|
} t_ttrmn;
|
|
|
|
typedef struct s_node
|
|
{
|
|
struct s_node *left;
|
|
struct s_node *right;
|
|
struct s_node *up;
|
|
struct s_node *down;
|
|
int row;
|
|
struct s_node *column;
|
|
t_coord coord;
|
|
} t_node;
|
|
|
|
extern t_ttrmn g_templates[19];
|
|
|
|
// reads from file
|
|
char *read_file(char *path);
|
|
|
|
// convert string to table by spliting by '\n'
|
|
char **to_table(char **string);
|
|
|
|
// print table returned by to_table()
|
|
void print_table(char **table);
|
|
|
|
// creates new table where each string represent whole figrure
|
|
char **glue_figure(char **table);
|
|
|
|
// move tetromino in top left corner
|
|
void move_up_left(char **table);
|
|
|
|
// print table returned by glue_figure()
|
|
void print_one_string(t_ttrmn ttr);
|
|
|
|
// compare 19 templates with each tetromino in *ttr table
|
|
void test_check(char **ttr, t_ttrmn *tamplates);
|
|
|
|
// change hashes ('#') with letters
|
|
// obsolete, rewrite for structs array
|
|
void to_letters(char **ttr);
|
|
|
|
// create array of ttr structures
|
|
int *to_strct_array(char **ttr, t_ttrmn *templates);
|
|
|
|
t_node *add_column(t_node *root);
|
|
|
|
t_node *add_node(t_node *col, int row);
|
|
|
|
void cover(t_node *to_cover);
|
|
|
|
void uncover(t_node *to_uncover);
|
|
|
|
int *get_types(char **ttr);
|
|
|
|
#endif
|