aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-14 17:49:13 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-14 17:49:13 +0100
commit1dbbfa8cc8455ca34931f43d631f203539e8a95d (patch)
tree9a22319167390a67792a9d64c9449a5109dfa5eb /src
parentTrying death screen (diff)
download42-cub3d-1dbbfa8cc8455ca34931f43d631f203539e8a95d.tar.gz
42-cub3d-1dbbfa8cc8455ca34931f43d631f203539e8a95d.tar.bz2
42-cub3d-1dbbfa8cc8455ca34931f43d631f203539e8a95d.tar.xz
42-cub3d-1dbbfa8cc8455ca34931f43d631f203539e8a95d.tar.zst
42-cub3d-1dbbfa8cc8455ca34931f43d631f203539e8a95d.zip
Almost there
Diffstat (limited to 'src')
-rw-r--r--src/ft_death_screen.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/ft_death_screen.c b/src/ft_death_screen.c
index 80ba23c..13aa7cf 100644
--- a/src/ft_death_screen.c
+++ b/src/ft_death_screen.c
@@ -18,20 +18,38 @@
static void
ft_draw_death_screen(t_cub *cl)
{
- uint16_t x;
- uint16_t y;
+ int32_t x_ratio;
+ int32_t y_ratio;
+ int32_t x;
+ int32_t y;
- x = 0;
+ 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 (x < cl->wlist.x_size)
+ while (y < (int32_t)cl->wlist.y_size)
{
- while (y < cl->wlist.y_size)
+ x = 0;
+ while (x < (int32_t)cl->wlist.x_size)
{
- /* cl->death_screen.tex_x = ; */
- /* cl->death_screen.tex_y = ; */
+ cl->death_screen.tex_x = ((x * x_ratio) >> 16);
+ cl->death_screen.tex_y = ((y * y_ratio) >> 16);
+ cl->img.ptr[x * 4 + (cl->img.sizeline * y)] =
+ (uint8_t)cl->death_screen.ptr[cl->death_screen.tex_x * 4 + 4 *
+ cl->death_screen.img_h * cl->death_screen.tex_y];
+ /* cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 1] = */
+ /* (uint8_t)cl->death_screen.ptr[cl->death_screen.tex_x * 4 + 4 * */
+ /* cl->death_screen.img_h * cl->death_screen.tex_y + 1]; */
+ /* cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 2] = */
+ /* (uint8_t)cl->death_screen.ptr[cl->death_screen.tex_x * 4 + 4 * */
+ /* cl->death_screen.img_h * cl->death_screen.tex_y + 2]; */
+ /* cl->img.ptr[x * 4 + cl->wlist.x_size * y + 3] = (char)0; */
x++;
}
- x = 0;
y++;
}
}
@@ -39,11 +57,6 @@ static void
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,