int ft_key_hook(int keycode, t_env *e) { if (e && (keycode == ESC)) { write(1, "You've quit the program.\n", 25); exit(0); } else { if (e && (keycode == CTRL)) e->img->angle += M_PI; else if (e && (keycode == 99)) ft_get_color(e); else if (e && (keycode == 114)) { e->img->pos_x = 1.0; e->img->pos_y = 1.0; e->img->angle = 0.0; e->img->color = 0x4B0082; } ft_move(e, keycode); ft_draw_wall(e); } return (0); }
void ft_draw_img() { int x; int y; double wall_height; double wall_dist; x = WIN_WID - 1; while (x >= 0) { //printf("x = %d\n", x); wall_dist = ft_wall_distance(x); printf("Pour x = %d wall_dist->%f\n", x, wall_dist); //ft_putstr("\n"); wall_height = STEP / wall_dist * POV; printf("hauteur a l ecran = %f\n", wall_height); /*if (wall_height > WIN_HEI) wall_height = WIN_HEI - 1;*/ y = (WIN_HEI / 2) - 1 - (wall_height / 2); /* on dessine le plafond */ ft_draw_ceiling(x, y); /* on dessine le mur */ ft_draw_wall(wall_height, x, y); /* on dessine le floor */ ft_draw_floor(x, WIN_HEI / 2 + wall_height / 2 - 1); /*if (x == WIN_WID - 64) break ; */ x--; } }
static void ft_init_env(t_env *e) { t_img *i; i = e->img; i->img = mlx_new_image(e->mlx, WIDTH, HEIGHT); i->addr = mlx_get_data_addr(i->img, &i->bpp, &i->ln_size, &i->endian); i->color = 0x4B0082; i->pos_x = 1.0; i->pos_y = 1.0; i->angle = 0.0; ft_draw_wall(e); mlx_put_image_to_window(e->mlx, e->win, i->img, 0, 0); }
void ft_draw(t_mlx *mx, int x) { int y; int pixel; if (mx->v.drawend < 0) return ; y = -1; while (++y < HEIGHT) { pixel = (y * mx->width * 4) + x * 4; if (y < mx->v.drawstart) ft_draw_sky(mx, x, y, pixel); else if (y < mx->v.drawend) ft_draw_wall(mx, y, pixel); else ft_draw_floor(mx, x, y, pixel); } }