diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 17:45:53 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-18 17:45:53 +0100 |
commit | ded508c2018294c3bcb79b82dcf6874e12569b97 (patch) | |
tree | 10d2a086cdcacf35a8560eae6ac046302ace66d1 /src | |
parent | Minimap back (diff) | |
download | 42-cub3d-ded508c2018294c3bcb79b82dcf6874e12569b97.tar.gz 42-cub3d-ded508c2018294c3bcb79b82dcf6874e12569b97.tar.bz2 42-cub3d-ded508c2018294c3bcb79b82dcf6874e12569b97.tar.xz 42-cub3d-ded508c2018294c3bcb79b82dcf6874e12569b97.tar.zst 42-cub3d-ded508c2018294c3bcb79b82dcf6874e12569b97.zip |
Removed bloat
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_death_screen.c | 1 | ||||
-rw-r--r-- | src/ft_draw_hud.c | 52 | ||||
-rw-r--r-- | src/ft_draw_sprite.c | 1 | ||||
-rw-r--r-- | src/ft_draw_textures.c | 1 | ||||
-rw-r--r-- | src/ft_draw_traps.c | 1 | ||||
-rw-r--r-- | src/ft_exit.c | 2 | ||||
-rw-r--r-- | src/ft_floor_cast.c | 22 |
7 files changed, 27 insertions, 53 deletions
diff --git a/src/ft_death_screen.c b/src/ft_death_screen.c index e8ddc3a..55a61cb 100644 --- a/src/ft_death_screen.c +++ b/src/ft_death_screen.c @@ -38,7 +38,6 @@ static void 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_w * cl->death_screen.tex_y + 2]; - cl->img.ptr[x * 4 + cl->wlist.x_size * y + 3] = (char)0; x++; } y++; diff --git a/src/ft_draw_hud.c b/src/ft_draw_hud.c index 3db6b60..fff75b0 100644 --- a/src/ft_draw_hud.c +++ b/src/ft_draw_hud.c @@ -13,34 +13,19 @@ #include <cub3d.h> #include <stdint.h> -/* static void */ -/* ft_draw_minimap_back(size_t map_h, size_t map_w, t_win *wl, t_cub *cl) */ -/* { */ -/* const uint16_t scl = cl->mlist.scale; */ -/* uint32_t x; */ -/* uint32_t y; */ -/* int32_t col; */ - -/* col = 0x00353535; */ -/* x = 0; */ -/* y = wl->y_size - (map_h * scl) - 20; */ -/* while (x < (map_w * scl) + 20 + (3 * scl)) */ -/* { */ -/* while (y < wl->y_size) */ -/* { */ -/* *(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = col; */ -/* if (!(y % 3)) */ -/* { */ -/* if (col < 0x00aaaaaa) */ -/* col += 0x00010101; */ -/* } */ -/* y++; */ -/* } */ -/* col = 0x00353535; */ -/* y = wl->y_size - (map_h * scl) - 20; */ -/* x++; */ -/* } */ -/* } */ +static void + ft_put_image_back_to_ptr(uint16_t y, uint16_t x, t_cub *cl) +{ + *(cl->img.ptr + x * 4 + (cl->img.sizeline * y)) = + (uint8_t)*(cl->tlist[16].ptr + cl->tlist[16].tex_x * 4 + 4 * + cl->tlist[16].img_w * cl->tlist[16].tex_y); + *(cl->img.ptr + x * 4 + (cl->img.sizeline * y) + 1) = + (uint8_t)*(cl->tlist[16].ptr + cl->tlist[16].tex_x * 4 + 4 * + cl->tlist[16].img_w * cl->tlist[16].tex_y + 1); + *(cl->img.ptr + x * 4 + (cl->img.sizeline * y) + 2) = + (uint8_t)*(cl->tlist[16].ptr + cl->tlist[16].tex_x * 4 + 4 * + cl->tlist[16].img_w * cl->tlist[16].tex_y + 2); +} static void ft_draw_minimap_back_image(uint16_t h, uint16_t w, t_cub *cl) @@ -61,16 +46,7 @@ static void * cl->mlist.scale) + 20 + (3 * cl->mlist.scale))) { cl->tlist[16].tex_x = (x * x_ratio) >> 16; - cl->img.ptr[x * 4 + (cl->img.sizeline * y)] = - (uint8_t)cl->tlist[16].ptr[cl->tlist[16].tex_x * 4 + 4 * - cl->tlist[16].img_w * cl->tlist[16].tex_y]; - cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 1] = - (uint8_t)cl->tlist[16].ptr[cl->tlist[16].tex_x * 4 + 4 * - cl->tlist[16].img_w * cl->tlist[16].tex_y + 1]; - cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 2] = - (uint8_t)cl->tlist[16].ptr[cl->tlist[16].tex_x * 4 + 4 * - cl->tlist[16].img_w * cl->tlist[16].tex_y + 2]; - cl->img.ptr[x * 4 + cl->wlist.x_size * y + 3] = (char)0; + ft_put_image_back_to_ptr(y, x, cl); x++; } y++; diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c index 73f277a..b304102 100644 --- a/src/ft_draw_sprite.c +++ b/src/ft_draw_sprite.c @@ -84,7 +84,6 @@ static void cl->img.ptr[sprite->x * 4 + (sprite->y * cl->img.sizeline) + 2] = (uint8_t)cl->tlist[sprite->current_sprite].ptr[sprite->tex_x * 4 + 4 * cl->tlist[sprite->current_sprite].img_h * sprite->tex_y + 2] / calc; - cl->img.ptr[sprite->x * 4 + cl->wlist.x_size * sprite->y + 3] = (char)0; } void diff --git a/src/ft_draw_textures.c b/src/ft_draw_textures.c index 5fc3bdd..dcd36e7 100644 --- a/src/ft_draw_textures.c +++ b/src/ft_draw_textures.c @@ -41,7 +41,6 @@ void ft_draw_texture(t_cub *cl, int x, int y, int tex_y) cl->img.ptr[x * 4 + (cl->img.sizeline * y) + 2] = (uint8_t)cl->tlist[cl->w_side].ptr[cl->tlist[cl->w_side].tex_x * 4 + 4 * cl->tlist[cl->w_side].img_h * tex_y + 2] / calc; - cl->img.ptr[x * 4 + cl->wlist.x_size * y + 3] = (char)0; } void ft_choose_tex(t_cub *clist) diff --git a/src/ft_draw_traps.c b/src/ft_draw_traps.c index abde37e..8bf2221 100644 --- a/src/ft_draw_traps.c +++ b/src/ft_draw_traps.c @@ -77,7 +77,6 @@ static void cl->img.ptr[sprite->x * 4 + (sprite->y * cl->img.sizeline) + 2] = (uint8_t)cl->tlist[15].ptr[sprite->tex_x * 4 + 4 * cl->tlist[15].img_h * sprite->tex_y + 2] / calc; - cl->img.ptr[sprite->x * 4 + cl->wlist.x_size * sprite->y + 3] = (char)0; } void diff --git a/src/ft_exit.c b/src/ft_exit.c index 61f925e..78b6d0a 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -84,6 +84,8 @@ static void mlx_destroy_image(clist->wlist.wlx, clist->tlist[7].img); if (clist->mlist.istraps && clist->tlist[15].img) mlx_destroy_image(clist->wlist.wlx, clist->tlist[15].img); + if (clist->tlist[16].img) + mlx_destroy_image(clist->wlist.wlx, clist->tlist[16].img); ft_del_extra_sprites(clist); } diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c index 92dcb07..160a2c1 100644 --- a/src/ft_floor_cast.c +++ b/src/ft_floor_cast.c @@ -25,30 +25,30 @@ static void { float dist; float calc; - t_rgb rgb; dist = (cl->rlist.row_dist > 0) ? (cl->rlist.row_dist) : (0.0001); calc = (dist * 0.1 * cl->mlist.darklvl); calc = (calc >= 255) ? (255) : (calc); calc = (calc < 1) ? (1) : (calc); calc = (cl->mlist.darklvl > 0) ? (calc) : (1); - rgb.r = (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x * 4 + 4 * - cl->tlist[tid].img_h * cl->tlist[tid].tex_y + 2] / calc; - rgb.g = (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x * 4 + 4 * - cl->tlist[tid].img_h * cl->tlist[tid].tex_y + 1] / calc; - rgb.b = (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x * 4 + 4 * - cl->tlist[tid].img_h * cl->tlist[tid].tex_y] / calc; - *(int*)(cl->img.ptr + - (x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(rgb); + *(cl->img.ptr + x * 4 + (cl->img.sizeline * y)) = + (uint8_t)*(cl->tlist[tid].ptr + cl->tlist[tid].tex_x * 4 + 4 * + cl->tlist[tid].img_w * cl->tlist[tid].tex_y) / calc; + *(cl->img.ptr + x * 4 + (cl->img.sizeline * y) + 1) = + (uint8_t)*(cl->tlist[tid].ptr + cl->tlist[tid].tex_x * 4 + 4 * + cl->tlist[tid].img_w * cl->tlist[tid].tex_y + 1) / calc; + *(cl->img.ptr + x * 4 + (cl->img.sizeline * y) + 2) = + (uint8_t)*(cl->tlist[tid].ptr + cl->tlist[tid].tex_x * 4 + 4 * + cl->tlist[tid].img_w * cl->tlist[tid].tex_y + 2) / calc; } static void ft_set_tex_xy(uint8_t tid, t_ray *rl, t_cub *cl) { cl->tlist[tid].tex_y = (int32_t)(cl->tlist[tid].img_w - * (rl->x_floor - rl->x_cell)) % (cl->tlist[tid].img_w); + * (rl->x_floor - rl->x_cell)); cl->tlist[tid].tex_x = (int32_t)(cl->tlist[tid].img_h - * (rl->y_floor - rl->y_cell)) % (cl->tlist[tid].img_h); + * (rl->y_floor - rl->y_cell)); cl->tlist[tid].tex_x = (cl->tlist[tid].tex_x > 0) ? (cl->tlist[tid].tex_x) : (-cl->tlist[tid].tex_x); cl->tlist[tid].tex_y = (cl->tlist[tid].tex_y > 0) |