mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
fix: various rendering issues
- Correct rendering on whole window if window is not square - Multiple crashes eliminated - Sprites no longer lag behind player movement/rotation
This commit is contained in:
parent
98e0119c91
commit
fcb08f6447
4 changed files with 9 additions and 11 deletions
|
|
@ -6,15 +6,15 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:54:36 by kcolin #+# #+# */
|
||||
/* Updated: 2025/08/07 13:45:34 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/08/12 14:32:47 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CONSTS_H
|
||||
# define CONSTS_H
|
||||
|
||||
# define HEIGHT 800
|
||||
# define WIDTH 800
|
||||
# define HEIGHT 600
|
||||
|
||||
# define SIZE 64
|
||||
# define MAP_SIZE 10
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:28:56 by kcolin #+# #+# */
|
||||
/* Updated: 2025/08/06 14:02:08 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/08/12 14:30:49 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ void my_mlx_pixel_put(t_img_data *data, int x, int y, int color)
|
|||
{
|
||||
char *dst;
|
||||
|
||||
if (x < 0 || y < 0 || x >= HEIGHT || y >= WIDTH)
|
||||
if (x < 0 || y < 0 || x >= WIDTH || y >= HEIGHT)
|
||||
return ;
|
||||
dst = data->addr + (y * data->line_length + x * (data->bits_per_pixel / 8));
|
||||
*(unsigned int *)dst = color;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
||||
/* Updated: 2025/08/11 11:03:22 by tchampio ### ########.fr */
|
||||
/* Updated: 2025/08/12 14:23:27 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -39,11 +39,9 @@ int game_loop(t_cub3d_data *data)
|
|||
char *fps_string;
|
||||
|
||||
data->last_tick = get_milliseconds();
|
||||
mlx_destroy_image(data->mlx, data->img_data->img);
|
||||
data->img_data->img = mlx_new_image(data->mlx, WIDTH, HEIGHT);
|
||||
reset_matrix(data);
|
||||
raycaster(data, &ray);
|
||||
move_player(data);
|
||||
raycaster(data, &ray);
|
||||
sprite_caster(data);
|
||||
matrix_to_image(data);
|
||||
draw_map(data->map, &data->player, data->img_data);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/31 13:18:17 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/31 13:38:49 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/08/12 14:31:04 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,12 +23,12 @@ void reset_matrix(t_cub3d_data *data)
|
|||
|
||||
int matrix_get(t_cub3d_data *data, int x, int y)
|
||||
{
|
||||
return (data->screen_matrix[y + x * WIDTH]);
|
||||
return (data->screen_matrix[y + x * HEIGHT]);
|
||||
}
|
||||
|
||||
void matrix_set(t_cub3d_data *data, int x, int y, int color)
|
||||
{
|
||||
data->screen_matrix[y + x * WIDTH] = color;
|
||||
data->screen_matrix[y + x * HEIGHT] = color;
|
||||
}
|
||||
|
||||
void matrix_to_image(t_cub3d_data *data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue