mirror of
https://github.com/Ladebeze66/cub3D.git
synced 2026-11-09 13:47:10 +01:00
versiontexturecouleur
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/14 20:09:23 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/01/14 20:16:05 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/01/17 21:15:02 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,6 +19,7 @@ void init_player(t_structure_main *w)
|
||||
w->s_player.pa = 0.1;
|
||||
w->s_player.pdx = cos(w->s_player.pa) * 5;
|
||||
w->s_player.pdy = sin(w->s_player.pa) * 5;
|
||||
printf("DEBUG: pdx = %f, pdy = %f\n", w->s_player.pdx, w->s_player.pdy);
|
||||
}
|
||||
|
||||
void init_mlx_and_window(t_structure_main *w)
|
||||
|
||||
81
window/ft_refresh_window.c
Normal file
81
window/ft_refresh_window.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_refresh_window.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/15 19:50:24 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/01/15 19:51:24 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../cub3d.h"
|
||||
|
||||
void rescale_sprite(t_structure_main *w, t_state *state)
|
||||
{
|
||||
t_rescale_params params;
|
||||
|
||||
params.original_img = w->s_img.roomadslam[state->jkl];
|
||||
params.original_width = 112;
|
||||
params.original_height = 112;
|
||||
params.new_width = w->s_map.mapS;
|
||||
params.new_height = w->s_map.mapS;
|
||||
params.px = w->s_player.px - w->s_map.mapS / 2;
|
||||
params.py = w->s_player.py - w->s_map.mapS / 2;
|
||||
rescale_image(¶ms, w);
|
||||
}
|
||||
|
||||
void refresh_window(t_structure_main *w, t_state *state)
|
||||
{
|
||||
mlx_destroy_image(w->s_win.mlx, w->s_img.buffer);
|
||||
w->s_img.buffer = mlx_new_image(w->s_win.mlx, w->s_win.width,
|
||||
w->s_win.height);
|
||||
w->s_img.addr = mlx_get_data_addr(w->s_img.buffer,
|
||||
&(w->s_img.bpp), &(w->s_img.line_len), &(w->s_img.endian));
|
||||
draw_map(w);
|
||||
drawrays2d(w);
|
||||
mlx_put_image_to_window(w->s_win.mlx, w->s_win.win, w->s_img.buffer, 0, 0);
|
||||
rescale_sprite(w, state);
|
||||
}
|
||||
|
||||
void handle_mouse_movement(t_structure_main *w)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
mlx_mouse_get_pos(w->s_win.mlx, w->s_win.win, &x, &y);
|
||||
if ((x > 0 && x < w->s_win.height) && (y > 0 && y < w->s_win.width))
|
||||
{
|
||||
if (x != w->s_win.height / 2)
|
||||
{
|
||||
if (x < w->s_win.height / 2)
|
||||
deal_key(65361, w);
|
||||
else
|
||||
deal_key(65363, w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void r_window(t_structure_main *w, t_state *state)
|
||||
{
|
||||
refresh_window(w, state);
|
||||
}
|
||||
|
||||
void sleep_mouse(t_global_struct *global_struct)
|
||||
{
|
||||
if (global_struct->state.yui < 10)
|
||||
{
|
||||
usleep(1000);
|
||||
global_struct->state.yui++;
|
||||
}
|
||||
else
|
||||
{
|
||||
global_struct->state.yui = 0;
|
||||
global_struct->state.jkl++;
|
||||
r_window(global_struct->w, &global_struct->state);
|
||||
handle_mouse_movement(global_struct->w);
|
||||
}
|
||||
if (global_struct->state.jkl == 10)
|
||||
global_struct->state.jkl = -1;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/14 19:15:53 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/01/14 20:15:35 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/01/17 21:26:12 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user