diff options
Diffstat (limited to 'src/ft_death_screen.c')
-rw-r--r-- | src/ft_death_screen.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/ft_death_screen.c b/src/ft_death_screen.c index e860c56..de8bcc9 100644 --- a/src/ft_death_screen.c +++ b/src/ft_death_screen.c @@ -16,20 +16,11 @@ #include <unistd.h> static void - ft_draw_death_screen(t_cub *cl) + ft_draw_death_screen(int32_t x_ratio, int32_t y_ratio, t_cub *cl) { - int32_t x_ratio; - int32_t y_ratio; int32_t x; int32_t y; - cl->death_screen.img = mlx_xpm_file_to_image(cl->wlist.wlx, - FT_DEATH_SCREEN_PATH, &cl->death_screen.img_w, &cl->death_screen.img_h); - cl->death_screen.ptr = mlx_get_data_addr(cl->death_screen.img, - &cl->death_screen.bpp, &cl->death_screen.sizeline, - &cl->death_screen.endian); - x_ratio = (int)((cl->death_screen.img_w << 16) / cl->wlist.x_size) + 1; - y_ratio = (int)((cl->death_screen.img_h << 16) / cl->wlist.y_size) + 1; y = 0; while (y < (int32_t)cl->wlist.y_size) { @@ -54,14 +45,30 @@ static void } } +static void + ft_calc_death_screen(t_cub *cl) +{ + int32_t x_ratio; + int32_t y_ratio; + + x_ratio = (int)((cl->death_screen.img_w << 16) / cl->wlist.x_size) + 1; + y_ratio = (int)((cl->death_screen.img_h << 16) / cl->wlist.y_size) + 1; + ft_draw_death_screen(x_ratio, y_ratio, cl); +} + void ft_death_screen(t_cub *cl) { + cl->death_screen.img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_DEATH_SCREEN_PATH, &cl->death_screen.img_w, &cl->death_screen.img_h); + cl->death_screen.ptr = mlx_get_data_addr(cl->death_screen.img, + &cl->death_screen.bpp, &cl->death_screen.sizeline, + &cl->death_screen.endian); 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); - ft_draw_death_screen(cl); + ft_calc_death_screen(cl); mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr, cl->img.img, 0, 0); ft_hooks_and_loops(&cl->wlist, cl); |