From b236416db21d03f7749e1c80d5b7abee70ea07d5 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 11 Mar 2020 12:38:21 +0100 Subject: Pretty cool animation --- src/ft_suffer_animation.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/ft_suffer_animation.c (limited to 'src/ft_suffer_animation.c') diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c new file mode 100644 index 0000000..bb69b4b --- /dev/null +++ b/src/ft_suffer_animation.c @@ -0,0 +1,44 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_key_loop.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/17 20:06:26 by rbousset #+# #+# */ +/* Updated: 2020/02/17 20:06:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include +#include + +void + ft_suffer_animation(t_cub *cl) +{ + uint16_t x; + uint16_t y; + + cl->img.img = mlx_new_image(cl->wlist.wlx, + cl->wlist.x_size, cl->wlist.y_size); + cl->img.ptr = mlx_get_data_addr(cl->img.img, &cl->img.bpp, + &cl->img.sizeline, &cl->img.endian); + x = 0; + y = 0; + while (y < cl->wlist.y_size) + { + while (x < cl->wlist.x_size) + { + *(int*)(cl->img.ptr + + (x * 4 + (y * cl->img.sizeline))) = 0x00ce1212; + x++; + } + x = 0; + y++; + } + mlx_put_image_to_window(cl->wlist.wlx, + cl->wlist.winptr, cl->img.img, 0, 0); + mlx_destroy_image(cl->wlist.wlx, cl->img.img); +} -- cgit v1.2.3 From 878b565e98728dcd0fba8dfeeba8b1ff46dbd5cd Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 11 Mar 2020 12:48:34 +0100 Subject: Tweaked suff animation --- src/ft_suffer_animation.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/ft_suffer_animation.c') diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index bb69b4b..4e77ca7 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -20,25 +20,31 @@ void { uint16_t x; uint16_t y; + uint8_t i; - cl->img.img = mlx_new_image(cl->wlist.wlx, - cl->wlist.x_size, cl->wlist.y_size); - cl->img.ptr = mlx_get_data_addr(cl->img.img, &cl->img.bpp, - &cl->img.sizeline, &cl->img.endian); - x = 0; - y = 0; - while (y < cl->wlist.y_size) + i = 0; + while (i < 8) { - while (x < cl->wlist.x_size) + cl->img.img = mlx_new_image(cl->wlist.wlx, + cl->wlist.x_size, cl->wlist.y_size); + cl->img.ptr = mlx_get_data_addr(cl->img.img, &cl->img.bpp, + &cl->img.sizeline, &cl->img.endian); + x = 0; + y = 0; + while (y < cl->wlist.y_size) { - *(int*)(cl->img.ptr + - (x * 4 + (y * cl->img.sizeline))) = 0x00ce1212; - x++; + while (x < cl->wlist.x_size) + { + *(int*)(cl->img.ptr + + (x * 4 + (y * cl->img.sizeline))) = 0x00ce1212; + x++; + } + x = 0; + y++; } - x = 0; - y++; + mlx_put_image_to_window(cl->wlist.wlx, + cl->wlist.winptr, cl->img.img, 0, 0); + mlx_destroy_image(cl->wlist.wlx, cl->img.img); + i++; } - mlx_put_image_to_window(cl->wlist.wlx, - cl->wlist.winptr, cl->img.img, 0, 0); - mlx_destroy_image(cl->wlist.wlx, cl->img.img); } -- cgit v1.2.3 From 17906f353bb6e87528f552891d7d4c91bb3ac789 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 11 Mar 2020 14:38:52 +0100 Subject: why macos --- src/ft_suffer_animation.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'src/ft_suffer_animation.c') diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index 4e77ca7..a2ce3b1 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -18,33 +18,30 @@ void ft_suffer_animation(t_cub *cl) { - uint16_t x; - uint16_t y; - uint8_t i; + int32_t x; + int32_t y; + int8_t i; + int32_t col; - i = 0; - while (i < 8) + i = -1; + col = 0x00ce2524; + while (++i < 100) { - cl->img.img = mlx_new_image(cl->wlist.wlx, - cl->wlist.x_size, cl->wlist.y_size); - cl->img.ptr = mlx_get_data_addr(cl->img.img, &cl->img.bpp, - &cl->img.sizeline, &cl->img.endian); - x = 0; - y = 0; - while (y < cl->wlist.y_size) + cl->red_scr.img = mlx_new_image(cl->wlist.wlx, + cl->wlist.x_size, cl->wlist.y_size); + cl->red_scr.ptr = mlx_get_data_addr(cl->red_scr.img, &cl->red_scr.bpp, + &cl->red_scr.sizeline, &cl->red_scr.endian); + x = -1; + y = -1; + while (++y < (int32_t)cl->wlist.y_size) { - while (x < cl->wlist.x_size) - { - *(int*)(cl->img.ptr + - (x * 4 + (y * cl->img.sizeline))) = 0x00ce1212; - x++; - } - x = 0; - y++; + while (++x < (int32_t)cl->wlist.x_size) + *(int*)(cl->red_scr.ptr + + (x * 4 + (y * cl->red_scr.sizeline))) = col; + x = -1; } mlx_put_image_to_window(cl->wlist.wlx, - cl->wlist.winptr, cl->img.img, 0, 0); - mlx_destroy_image(cl->wlist.wlx, cl->img.img); - i++; + cl->wlist.winptr, cl->red_scr.img, 0, 0); + mlx_destroy_image(cl->wlist.wlx, cl->red_scr.img); } } -- cgit v1.2.3 From 650e83573987d004171f250e236b21b243477355 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 11 Mar 2020 14:57:54 +0100 Subject: is not working --- src/ft_suffer_animation.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/ft_suffer_animation.c') diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index a2ce3b1..3d3595a 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -21,11 +21,9 @@ void int32_t x; int32_t y; int8_t i; - int32_t col; i = -1; - col = 0x00ce2524; - while (++i < 100) + while (++i < 15) { cl->red_scr.img = mlx_new_image(cl->wlist.wlx, cl->wlist.x_size, cl->wlist.y_size); @@ -37,7 +35,7 @@ void { while (++x < (int32_t)cl->wlist.x_size) *(int*)(cl->red_scr.ptr + - (x * 4 + (y * cl->red_scr.sizeline))) = col; + (x * 4 + (y * cl->red_scr.sizeline))) = 0x00ce2524; x = -1; } mlx_put_image_to_window(cl->wlist.wlx, -- cgit v1.2.3 From 114df1314a69161e5802ce6192aa8f1599867f3e Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 11 Mar 2020 15:30:51 +0100 Subject: qweqwe --- src/ft_suffer_animation.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/ft_suffer_animation.c') diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index 3d3595a..2a1beb4 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -14,6 +14,7 @@ #include #include #include +#include void ft_suffer_animation(t_cub *cl) @@ -22,24 +23,22 @@ void int32_t y; int8_t i; - i = -1; - while (++i < 15) + /* cl->red_scr.img = mlx_new_image(cl->wlist.wlx, */ + /* cl->wlist.x_size, cl->wlist.y_size); */ + /* cl->red_scr.ptr = mlx_get_data_addr(cl->red_scr.img, &cl->red_scr.bpp, */ + /* &cl->red_scr.sizeline, &cl->red_scr.endian); */ + y = -1; + while (++y < (int32_t)cl->wlist.y_size) { - cl->red_scr.img = mlx_new_image(cl->wlist.wlx, - cl->wlist.x_size, cl->wlist.y_size); - cl->red_scr.ptr = mlx_get_data_addr(cl->red_scr.img, &cl->red_scr.bpp, - &cl->red_scr.sizeline, &cl->red_scr.endian); x = -1; - y = -1; - while (++y < (int32_t)cl->wlist.y_size) - { - while (++x < (int32_t)cl->wlist.x_size) - *(int*)(cl->red_scr.ptr + - (x * 4 + (y * cl->red_scr.sizeline))) = 0x00ce2524; - x = -1; - } - mlx_put_image_to_window(cl->wlist.wlx, - cl->wlist.winptr, cl->red_scr.img, 0, 0); - mlx_destroy_image(cl->wlist.wlx, cl->red_scr.img); + while (++x < (int32_t)cl->wlist.x_size) + *(int*)(cl->img.ptr + + (x * 4 + (y * cl->img.sizeline))) = 0x00ffffff; } + i = -1; + mlx_put_image_to_window(cl->wlist.wlx, + cl->wlist.winptr, cl->img.img, 0, 0); + sleep(5); + /* while (++i < 120) */ + /* mlx_destroy_image(cl->wlist.wlx, cl->red_scr.img); */ } -- cgit v1.2.3 From 7f77c9bc922fb608f689385d642304956afe0492 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 11 Mar 2020 16:07:29 +0100 Subject: Performance --- src/ft_suffer_animation.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/ft_suffer_animation.c') diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index 2a1beb4..1a9b51a 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -21,24 +21,26 @@ void { int32_t x; int32_t y; - int8_t i; + int32_t col; + t_rgb rgb; - /* cl->red_scr.img = mlx_new_image(cl->wlist.wlx, */ - /* cl->wlist.x_size, cl->wlist.y_size); */ - /* cl->red_scr.ptr = mlx_get_data_addr(cl->red_scr.img, &cl->red_scr.bpp, */ - /* &cl->red_scr.sizeline, &cl->red_scr.endian); */ y = -1; + col = 0x00880000; while (++y < (int32_t)cl->wlist.y_size) { x = -1; while (++x < (int32_t)cl->wlist.x_size) + { + rgb = ft_hex_to_og_rgb(*(int*)(cl->img.ptr + + (x * 4 + (y * cl->img.sizeline)))); + rgb.r += 120; *(int*)(cl->img.ptr + - (x * 4 + (y * cl->img.sizeline))) = 0x00ffffff; + (x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(rgb); + } + /* if (y < (int32_t)cl->wlist.y_size / 2) */ + /* col += 0x00000000; */ + /* else */ + /* col -= 0x00000000; */ } - i = -1; - mlx_put_image_to_window(cl->wlist.wlx, - cl->wlist.winptr, cl->img.img, 0, 0); - sleep(5); - /* while (++i < 120) */ - /* mlx_destroy_image(cl->wlist.wlx, cl->red_scr.img); */ + cl->doicast = 0; } -- cgit v1.2.3 From 7b61072321c71c1612a7b33d2e8d722a49c5bc99 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Wed, 11 Mar 2020 18:06:17 +0100 Subject: ca tue --- src/ft_suffer_animation.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ft_suffer_animation.c') diff --git a/src/ft_suffer_animation.c b/src/ft_suffer_animation.c index 1a9b51a..b800a39 100644 --- a/src/ft_suffer_animation.c +++ b/src/ft_suffer_animation.c @@ -21,11 +21,9 @@ void { int32_t x; int32_t y; - int32_t col; t_rgb rgb; y = -1; - col = 0x00880000; while (++y < (int32_t)cl->wlist.y_size) { x = -1; @@ -33,14 +31,16 @@ void { rgb = ft_hex_to_og_rgb(*(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline)))); - rgb.r += 120; + rgb.r += 150; + rgb.g += 20; + rgb.b += 20; *(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(rgb); } - /* if (y < (int32_t)cl->wlist.y_size / 2) */ - /* col += 0x00000000; */ - /* else */ - /* col -= 0x00000000; */ } + cl->plist.life -= 20; + if (cl->plist.life <= 0) + ft_exit(0, cl); + /* TODO death screen here */ cl->doicast = 0; } -- cgit v1.2.3