aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ft_draw_scene.c11
-rw-r--r--src/ft_hex_to_rgb.c11
-rw-r--r--src/ft_init_lists.c1
-rw-r--r--src/ft_key_loop.c7
-rw-r--r--src/ft_suffer_animation.c26
5 files changed, 33 insertions, 23 deletions
diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c
index 9664363..39cdadc 100644
--- a/src/ft_draw_scene.c
+++ b/src/ft_draw_scene.c
@@ -45,22 +45,19 @@ void
/* clist->wlist.x_size, clist->wlist.y_size); */
/* clist->img.ptr = mlx_get_data_addr(clist->img.img, &clist->img.bpp, */
/* &clist->img.sizeline, &clist->img.endian); */
- ft_castray(clist);
+ if (clist->doicast)
+ ft_castray(clist);
+ else
+ clist->doicast = 1;
if (clist->ishud)
- {
ft_draw_hud(clist);
- }
if (clist->mlist.isskybox)
ft_draw_skybox(clist);
mlx_put_image_to_window(clist->wlist.wlx,
clist->wlist.winptr, clist->img.img, 0, 0);
if (clist->ishud && clist->mlist.isnlvl)
- {
if (ft_put_stage(clist) < 0)
- {
ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, clist);
- }
- }
/* mlx_destroy_image(clist->wlist.wlx, clist->img.img); */
}
diff --git a/src/ft_hex_to_rgb.c b/src/ft_hex_to_rgb.c
index 30332cc..1732473 100644
--- a/src/ft_hex_to_rgb.c
+++ b/src/ft_hex_to_rgb.c
@@ -13,6 +13,17 @@
#include <cub3d.h>
#include <stdint.h>
+t_rgb
+ ft_hex_to_og_rgb(uint32_t color)
+{
+ t_rgb rgb;
+
+ rgb.r = (color >> 16) & 255;
+ rgb.g = (color >> 8) & 255;
+ rgb.b = color & 255;
+ return (rgb);
+}
+
t_bmp_rgb
ft_hex_to_rgb(uint32_t color)
{
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index 79b0d14..d480912 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -74,6 +74,7 @@ static int8_t
cl->key_input[i] = -1;
cl->ishud = 0;
cl->isoldmus = 0;
+ cl->doicast = 1;
cl->f_rgb = ft_init_rgb();
cl->c_rgb = ft_init_rgb();
cl->rlist = ft_init_s_ray();
diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c
index e0c2c28..45ed379 100644
--- a/src/ft_key_loop.c
+++ b/src/ft_key_loop.c
@@ -12,6 +12,7 @@
#include <libft.h>
#include <cub3d.h>
+#include <mlx.h>
#include <stdint.h>
#include <stddef.h>
@@ -55,8 +56,8 @@ static void
y = ft_find_y(key, pl);
if (cl->mlist.map[y][x] == 'T')
{
- pl->pos_x = old_x + ((old_x - x) / 4);
- pl->pos_y = old_y + ((old_y - y) / 4);
+ pl->pos_x = old_x + ((old_x - x) / 3);
+ pl->pos_y = old_y + ((old_y - y) / 3);
ft_suffer_animation(cl);
x = ft_find_x(key, pl);
y = ft_find_y(key, pl);
@@ -93,8 +94,6 @@ int
i++;
}
if (cl->key_input[0] != -1)
- {
ft_draw_scene(cl);
- }
return (0);
}
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;
}