En sois la vie tu né, tu fais rien et tu meurs
This commit is contained in:
parent
63eca2ab8e
commit
5c5d23c5f7
BIN
assets/red.png
BIN
assets/red.png
Binary file not shown.
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 631 B |
BIN
assets/red_.png
BIN
assets/red_.png
Binary file not shown.
Before Width: | Height: | Size: 631 B |
@ -6,7 +6,7 @@
|
||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/05/02 15:49:00 by erey-bet #+# #+# */
|
||||
/* Updated: 2023/05/09 15:05:37 by erey-bet ### ########.fr */
|
||||
/* Updated: 2023/05/10 13:40:52 by erey-bet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -116,8 +116,7 @@ static uint32_t switch_color_bytes(uint32_t bad)
|
||||
}
|
||||
|
||||
uint32_t get_pixel_color(mlx_texture_t *texture, uint32_t x, uint32_t y) {
|
||||
uint32_t *pixel_ptr = (uint32_t*)(texture->pixels + (y * texture->width + x) * texture->bytes_per_pixel);
|
||||
return switch_color_bytes(*pixel_ptr);
|
||||
return switch_color_bytes(*(uint32_t*)(texture->pixels + (y * texture->width + x) * texture->bytes_per_pixel));
|
||||
}
|
||||
|
||||
int get_texture_side(t_dda *dda)
|
||||
@ -151,12 +150,10 @@ void draw_texture(t_game *game, t_dda *dda, double x)
|
||||
|| (dda->side == 1 && game->ray.dir_y < 0))
|
||||
tex.x = tex.texture->width - tex.x - 1;
|
||||
tex.step = 1.0 * tex.texture->height / dda->line_height;
|
||||
tex.pos = (dda->draw_start - tex.texture->height / 2 + dda->line_height / 2) * tex.step;
|
||||
tex.pos = (dda->draw_start - game->window->height / 2 + dda->line_height / 2) * tex.step;
|
||||
y = dda->draw_start - 1;
|
||||
//printf("tex.x: %d\n", tex.x);
|
||||
while (++y < dda->draw_end)
|
||||
{
|
||||
//printf("tex.y: %d\n", tex.y);
|
||||
tex.y = (int)tex.pos & (tex.texture->height - 1);
|
||||
tex.pos += tex.step;
|
||||
mlx_put_pixel(game->window, x, y, get_pixel_color(tex.texture, tex.x, tex.y));
|
||||
|
Loading…
Reference in New Issue
Block a user