Skip to content

Commit 382477d

Browse files
committed
feat: add window management and read file function
1 parent 191e002 commit 382477d

File tree

13 files changed

+202
-266
lines changed

13 files changed

+202
-266
lines changed

Makefile

+5-12
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@ NAME = fdf
33
INC_DIR = inc
44
LIB_DIR = lib
55
LIBFT_DIR = $(LIB_DIR)/libft
6-
GNL_DIR = $(LIB_DIR)/get_next_line
76
MLX_DIR = $(LIB_DIR)/minilibx
87
LIBFT = $(LIBFT_DIR)/libft.a
9-
GNL = $(GNL_DIR)/libgnl.a
108
MLX = $(MLX_DIR)/libmlx.a
119
BUILD_DIR = build
1210

13-
SRCS = fdf.c
11+
SRCS = fdf.c window_management.c read_map.c
1412
OBJS = $(addprefix $(BUILD_DIR)/,$(SRCS:.c=.o))
15-
CFLAGS = -Wall -Wextra -Werror -I$(INC_DIR) -I$(LIBFT_DIR) -I$(GNL_DIR) -I$(MLX_DIR)
16-
LDFLAGS = -L$(LIBFT_DIR) -L$(GNL_DIR) -L$(MLX_DIR)
17-
LDLIBS = -lmlx -lft -lgnl -lXext -lX11 -lm
13+
CFLAGS = -Wall -Wextra -Werror -I$(INC_DIR) -I$(LIBFT_DIR) -I$(MLX_DIR)
14+
LDFLAGS = -L$(LIBFT_DIR) -L$(MLX_DIR)
15+
LDLIBS = -lmlx -lft -lXext -lX11 -lm
1816

1917
RM = rm -rf
2018

2119
all: $(NAME)
2220

23-
$(NAME): $(OBJS) $(LIBFT) $(MLX) $(GNL)
21+
$(NAME): $(OBJS) $(LIBFT) $(MLX)
2422
$(CC) $(CFLAGS) $(OBJS) -o $(NAME) $(LDFLAGS) $(LDLIBS)
2523

2624
$(BUILD_DIR):
@@ -32,22 +30,17 @@ $(BUILD_DIR)/%.o: %.c | $(BUILD_DIR)
3230
$(LIBFT):
3331
@make -C $(LIBFT_DIR)
3432

35-
$(GNL):
36-
@make -C $(GNL_DIR)
37-
3833
$(MLX):
3934
@make -C $(MLX_DIR)
4035

4136
clean:
4237
$(RM) $(BUILD_DIR)
4338
@make -C $(LIBFT_DIR) clean
44-
@make -C $(GNL_DIR) clean
4539
@make -C $(MLX_DIR) clean
4640

4741
fclean: clean
4842
$(RM) $(NAME)
4943
@make -C $(LIBFT_DIR) fclean
50-
@make -C $(GNL_DIR) fclean
5144

5245
re: fclean all
5346

fdf.c

+13-6
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@
66
/* By: ebabaogl <[email protected] +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2025/01/02 11:39:32 by ebabaogl #+# #+# */
9-
/* Updated: 2025/01/02 11:58:41 by ebabaogl ### ########.fr */
9+
/* Updated: 2025/01/02 16:47:26 by ebabaogl ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "mlx.h"
1413
#include "fdf.h"
14+
#include "window.h"
15+
#include "libft.h"
1516

17+
#include <stdio.h>
18+
#include <stdlib.h>
1619
int main()
1720
{
18-
t_data data;
21+
//t_vars vars;
22+
//t_mlx mlx;
1923

20-
data.mlx_ptr = mlx_init();
21-
data.win_ptr = mlx_new_window(data.mlx_ptr, WIDTH, HEIGHT, "FdF!!1!!!1");
22-
mlx_loop(data.mlx_ptr);
24+
char *map = read_file("test_maps/42.fdf");
25+
printf("%s", map);
26+
free(map);
27+
//vars.mlx = &mlx;
28+
//if (init_win(vars.mlx) == -1)
29+
return (1);
2330
}

inc/fdf.h

+18-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,31 @@
66
/* By: ebabaogl <[email protected] +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2025/01/02 11:39:37 by ebabaogl #+# #+# */
9-
/* Updated: 2025/01/02 12:15:22 by ebabaogl ### ########.fr */
9+
/* Updated: 2025/01/02 16:21:30 by ebabaogl ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#ifndef FDF_H
1414
# define FDF_H
1515

16-
# define WIDTH 1920
17-
# define HEIGHT 1080
16+
#define BUFFER_SIZE 30
1817

19-
typedef struct s_data
18+
# include "window.h"
19+
20+
typedef struct s_vars
21+
{
22+
t_mlx *mlx;
23+
} t_vars;
24+
25+
typedef struct s_point
2026
{
21-
void *mlx_ptr;
22-
void *win_ptr;
23-
} t_data;
27+
int x;
28+
int y;
29+
int z;
30+
int color;
31+
} t_point;
32+
33+
char *read_file(char *file_name);
34+
int init_win(t_mlx *mlx);
2435

2536
#endif
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
/* ************************************************************************** */
22
/* */
33
/* ::: :::::::: */
4-
/* get_next_line.h :+: :+: :+: */
4+
/* window.h :+: :+: :+: */
55
/* +:+ +:+ +:+ */
66
/* By: ebabaogl <[email protected] +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
8-
/* Created: 2024/11/03 11:09:46 by ebabaogl #+# #+# */
9-
/* Updated: 2024/11/03 14:40:10 by ebabaogl ### ########.fr */
8+
/* Created: 2025/01/02 13:34:08 by ebabaogl #+# #+# */
9+
/* Updated: 2025/01/02 15:12:21 by ebabaogl ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#ifndef GET_NEXT_LINE_H
14-
# define GET_NEXT_LINE_H
13+
#ifndef WINDOW_H
14+
# define WINDOW_H
1515

16-
# ifndef BUFFER_SIZE
17-
# define BUFFER_SIZE 5
18-
# endif
16+
# define WIN_WIDTH 1920
17+
# define WIN_HEIGHT 1080
1918

20-
# include <stddef.h>
19+
# define ON_DESTROY 17
2120

22-
char *get_next_line(int fd);
21+
# define ESC_KEY 65307
2322

24-
size_t ft_strlen(char *s);
25-
void *ft_memset(void *b, int c, size_t len);
26-
void *ft_calloc(size_t count, size_t size);
27-
char *ft_strchr(char *s, int c);
28-
char *ft_strjoin(char *s1, char *s2);
23+
// enum {
24+
// ON_KEYDOWN = 2,
25+
// ON_KEYUP = 3,
26+
// ON_MOUSEDOWN = 4,
27+
// ON_MOUSEUP = 5,
28+
// ON_MOUSEMOVE = 6,
29+
// ON_EXPOSE = 12,
30+
// ON_DESTROY = 17
31+
// };
2932

30-
#endif
33+
typedef struct s_mlx
34+
{
35+
void *mlx_ptr;
36+
void *win_ptr;
37+
} t_mlx;
38+
39+
#endif

lib/get_next_line/Makefile

-30
This file was deleted.

lib/get_next_line/get_next_line.c

-113
This file was deleted.

0 commit comments

Comments
 (0)