-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Astrid Geels
committed
Mar 14, 2022
1 parent
d8265b4
commit b6eed1a
Showing
62 changed files
with
1,946 additions
and
147 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,21 +6,15 @@ | |
/* By: ageels <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2022/03/02 22:03:13 by ageels #+# #+# */ | ||
/* Updated: 2022/03/02 22:03:16 by ageels ######## odam.nl */ | ||
/* Updated: 2022/03/14 17:56:25 by ageels ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#ifndef FDFLIB_H | ||
# define FDFLIB_H | ||
# include "MLX42/MLX42.h" | ||
# include <stdlib.h> | ||
# include <math.h> | ||
# include "get_next_line_copy/get_next_line.h" | ||
# include <fcntl.h> | ||
# include <sys/types.h> | ||
# include <sys/stat.h> | ||
# include <unistd.h> | ||
# include <sys/uio.h> | ||
# include <math.h> | ||
|
||
# define WIDTH 2000 | ||
# define HEIGHT 900 | ||
|
@@ -33,13 +27,15 @@ typedef struct s_int | |
int j; | ||
int fd; | ||
char *lines; | ||
char **dots; | ||
char **d; | ||
void *int_ptr; | ||
void *start_ptr; | ||
} t_int; | ||
|
||
typedef struct s_map | ||
{ | ||
t_img *img; | ||
t_mlx *mlx; | ||
char *path; | ||
int hor; | ||
int ver; | ||
|
@@ -51,13 +47,14 @@ typedef struct s_map | |
int offsety; | ||
int zoom; | ||
int steepness; | ||
float angle; | ||
} t_map; | ||
|
||
typedef struct s_var | ||
{ | ||
t_mlx *my_mlx; | ||
t_img *my_img; | ||
t_map mapdata; | ||
t_map *mapdata; | ||
char *path; | ||
} t_var; | ||
|
||
|
@@ -68,15 +65,15 @@ char *ft_strjoin(char const *s1, char const *s2); | |
char **ft_split(char const *s, char c); | ||
int ft_atoi(const char *str); | ||
int ft_isdigit(int c); | ||
void ft_map(char *path, t_map mdata, t_img *my_img, t_mlx *my_mlx); | ||
t_map ft_scan_map(t_map my_map); | ||
int **ft_make_map(t_map map); | ||
int ft_map(char *path, t_map *mdata, t_img *my_img, t_mlx *my_mlx); | ||
int ft_scan_map(t_map *my_map); | ||
int **ft_make_map(t_map *map); | ||
void ft_toomanylines(t_int *te, t_map *map); | ||
void ft_isometric(int *x, int *y, int z, int steepness); | ||
void ft_isometric(int *x, int *y, int z, t_map *mapdata); | ||
void ft_draw(int **map, t_map *mapdata, t_img *img, t_mlx *mlx); | ||
void ft_line(t_img *img, t_map *mapdata); | ||
void ft_stop(t_mlx *my_mlx); | ||
int ft_strncmp(const char *s1, const char *s2, size_t n); | ||
void ft_pixelputwrap(t_img *img, int x, int y, unsigned int color); | ||
void ft_pixelputwrap(t_img *img, const uint32_t x, const uint32_t y, unsigned int color); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: ageels <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2022/03/02 22:03:39 by ageels #+# #+# */ | ||
/* Updated: 2022/03/02 22:04:07 by ageels ######## odam.nl */ | ||
/* Updated: 2022/03/14 17:46:40 by ageels ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -17,7 +17,6 @@ | |
# include <sys/types.h> | ||
# include <sys/uio.h> | ||
# include <stdlib.h> | ||
# include <stdio.h> | ||
# define BUFFER_SIZE 4 | ||
|
||
char *get_next_line(int fd); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: ageels <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2022/02/11 18:18:32 by ageels #+# #+# */ | ||
/* Updated: 2022/03/02 22:04:27 by ageels ######## odam.nl */ | ||
/* Updated: 2022/03/14 18:19:28 by ageels ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -17,13 +17,13 @@ void ft_movey(t_mlx_key_cbdata keydata, t_var *var) | |
if (keydata.key == MLX_KEY_UP | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS)) | ||
{ | ||
var->mapdata.offsety -= 10; | ||
var->mapdata->offsety -= 10; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
if (keydata.key == MLX_KEY_DOWN | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS)) | ||
{ | ||
var->mapdata.offsety += 10; | ||
var->mapdata->offsety += 10; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
} | ||
|
@@ -33,47 +33,61 @@ void ft_movex(t_mlx_key_cbdata keydata, t_var *var) | |
if (keydata.key == MLX_KEY_LEFT | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS)) | ||
{ | ||
var->mapdata.offsetx -= 10; | ||
var->mapdata->offsetx -= 10; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
if (keydata.key == MLX_KEY_RIGHT | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS)) | ||
{ | ||
var->mapdata.offsetx += 10; | ||
var->mapdata->offsetx += 10; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
} | ||
|
||
void ft_zoom(t_mlx_key_cbdata keydata, t_var *var) | ||
void ft_zoomangle(t_mlx_key_cbdata keydata, t_var *var) | ||
{ | ||
if (keydata.key == MLX_KEY_M | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS) | ||
&& var->mapdata.zoom > 1) | ||
&& var->mapdata->zoom > 1) | ||
{ | ||
var->mapdata.zoom -= 2; | ||
var->mapdata->zoom -= 2; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
if (keydata.key == MLX_KEY_P | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS)) | ||
{ | ||
var->mapdata.zoom += 2; | ||
var->mapdata->zoom += 2; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
if (keydata.key == MLX_KEY_X | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS) | ||
&& var->mapdata->angle > 0.1) | ||
{ | ||
var->mapdata->angle -= 0.1; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
} | ||
|
||
void ft_steep(t_mlx_key_cbdata keydata, t_var *var) | ||
void ft_steepangle(t_mlx_key_cbdata keydata, t_var *var) | ||
{ | ||
if (keydata.key == MLX_KEY_S | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS)) | ||
{ | ||
var->mapdata.steepness += 1; | ||
var->mapdata->steepness += 1; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
if (keydata.key == MLX_KEY_F | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS) | ||
&& var->mapdata.steepness > 0) | ||
&& var->mapdata->steepness > 0) | ||
{ | ||
var->mapdata->steepness -= 1; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
if (keydata.key == MLX_KEY_Z | ||
&& (keydata.action == MLX_REPEAT || keydata.action == MLX_PRESS) | ||
&& var->mapdata->angle < ((M_PI / 4) - 0.1)) | ||
{ | ||
var->mapdata.steepness -= 1; | ||
var->mapdata->angle += 0.1; | ||
ft_map(var->path, var->mapdata, var->my_img, var->my_mlx); | ||
} | ||
} | ||
|
@@ -87,6 +101,6 @@ void ft_keypress(t_mlx_key_cbdata keydata, void *invar) | |
mlx_close_window(var->my_mlx); | ||
ft_movey(keydata, var); | ||
ft_movex(keydata, var); | ||
ft_zoom(keydata, var); | ||
ft_steep(keydata, var); | ||
ft_zoomangle(keydata, var); | ||
ft_steepangle(keydata, var); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: ageels <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2022/02/11 17:51:10 by ageels #+# #+# */ | ||
/* Updated: 2022/02/25 15:23:29 by ageels ######## odam.nl */ | ||
/* Updated: 2022/03/14 17:42:40 by ageels ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -92,3 +92,4 @@ int ft_strncmp(const char *s1, const char *s2, size_t n) | |
a++; | ||
return (((const unsigned char *)s1)[a] - ((const unsigned char *)s2)[a]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: ageels <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2022/02/11 18:18:27 by ageels #+# #+# */ | ||
/* Updated: 2022/03/02 21:17:10 by ageels ######## odam.nl */ | ||
/* Updated: 2022/03/14 17:49:16 by ageels ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -70,8 +70,6 @@ void ft_line(t_img *img, t_map *mapdata) | |
float xd; | ||
float yd; | ||
float mn[2]; | ||
int mypoint[2]; | ||
float basey; | ||
|
||
xd = mapdata->xb - mapdata->xa; | ||
yd = mapdata->yb - mapdata->ya; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,46 @@ | |
/* By: ageels <[email protected]> +#+ */ | ||
/* +#+ */ | ||
/* Created: 2022/02/11 16:58:15 by ageels #+# #+# */ | ||
/* Updated: 2022/03/02 21:32:48 by ageels ######## odam.nl */ | ||
/* Updated: 2022/03/14 17:54:27 by ageels ######## odam.nl */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "fdflib.h" | ||
#include "MLX42/MLX42.h" | ||
|
||
int ft_check_args(int num, char *filename) | ||
{ | ||
if (num != 2) | ||
{ | ||
write(1, "What map do you want?\n", 22); | ||
return (0); | ||
} | ||
if (ft_strncmp(filename, "test_maps/\0", 11) == 0 | ||
|| ft_strncmp(filename, "test_maps\0", 10) == 0) | ||
{ | ||
write(1, "issa folder", 11); | ||
return (0); | ||
} | ||
return (1); | ||
} | ||
|
||
void ft_putmapdata(t_mlx *my_mlx, t_img *my_img, t_map *mapdata) | ||
{ | ||
mapdata->mlx = my_mlx; | ||
mapdata->img = my_img; | ||
mapdata->offsetx = my_mlx->width / 2; | ||
mapdata->offsety = my_mlx->height / 4; | ||
mapdata->zoom = 15; | ||
mapdata->steepness = 3; | ||
mapdata->angle = 0.523599; | ||
} | ||
|
||
void ft_makevar(t_map *mapdata, char *path, t_var *my_var) | ||
{ | ||
my_var->my_mlx = mapdata->mlx; | ||
my_var->my_img = mapdata->img; | ||
my_var->mapdata = mapdata; | ||
my_var->path = path; | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
|
@@ -20,18 +54,18 @@ int main(int argc, char **argv) | |
t_img *my_img; | ||
t_map mapdata; | ||
|
||
if (ft_check_args(argc, argv[1]) == 0) | ||
return (0); | ||
my_mlx = mlx_init(WIDTH, HEIGHT, "frame it", false); | ||
my_img = mlx_new_image(my_mlx, my_mlx->width, my_mlx->height); | ||
mapdata.offsetx = my_mlx->width / 2; | ||
mapdata.offsety = my_mlx->height / 4; | ||
mapdata.zoom = 15; | ||
mapdata.steepness = 3; | ||
ft_map(argv[1], mapdata, my_img, my_mlx); | ||
ft_putmapdata(my_mlx, my_img, &mapdata); | ||
if (ft_map(argv[1], &mapdata, my_img, my_mlx) == -1) | ||
{ | ||
ft_stop(my_mlx); | ||
return (0); | ||
} | ||
mlx_image_to_window(my_mlx, my_img, 0, 0); | ||
my_var.my_mlx = my_mlx; | ||
my_var.my_img = my_img; | ||
my_var.mapdata = mapdata; | ||
my_var.path = argv[1]; | ||
ft_makevar(&mapdata, argv[1], &my_var); | ||
mlx_key_hook(my_mlx, ft_keypress, &my_var); | ||
mlx_loop(my_mlx); | ||
ft_stop(my_mlx); | ||
|
Oops, something went wrong.