suppression of the map view
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
/* screen focal (in degree) */
|
||||
# define SCREEN_FOCAL 70
|
||||
/* size of a cell on the map */
|
||||
# define CELL 40
|
||||
# define CELL 100
|
||||
|
||||
/*
|
||||
* keys macro
|
||||
|
||||
@@ -91,8 +91,6 @@ typedef struct s_txt
|
||||
char *txt_west;
|
||||
int rgb_floor;
|
||||
int rgb_ceiling;
|
||||
// int rgb_floor[3];
|
||||
// int rgb_ceiling[3];
|
||||
} t_txt;
|
||||
|
||||
/*
|
||||
@@ -146,9 +144,6 @@ typedef struct s_game
|
||||
t_txt txt;
|
||||
// map
|
||||
t_map map;
|
||||
// map window
|
||||
t_win map_win;
|
||||
t_img map_img;
|
||||
// key hook
|
||||
int k_hook[MAX_NB_KEY];
|
||||
} t_game;
|
||||
|
||||
@@ -5,15 +5,8 @@ void destroy_mlx(void *param)
|
||||
t_game *game;
|
||||
|
||||
game = param;
|
||||
|
||||
// tmp, to draw map
|
||||
mlx_destroy_image(game->mlx_ptr, game->map_img.ptr);
|
||||
mlx_destroy_window(game->mlx_ptr, game->map_win.ptr);
|
||||
// tmp end
|
||||
|
||||
mlx_destroy_image(game->mlx_ptr, game->img.ptr);
|
||||
mlx_destroy_window(game->mlx_ptr, game->win.ptr);
|
||||
|
||||
mlx_destroy_display(game->mlx_ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,102 +42,8 @@ void draw_line(t_img *img, t_vec *vec, int color)
|
||||
}
|
||||
}
|
||||
|
||||
// tmp
|
||||
static void draw_square(t_game *game, t_coord pos, int border, int fill, int size, int rotation)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
t_coord new;
|
||||
|
||||
i = 0;
|
||||
while (i < size)
|
||||
{
|
||||
j = 0;
|
||||
while (j < size)
|
||||
{
|
||||
new.x = pos.x + j;
|
||||
new.y = pos.y + i;
|
||||
if (rotation)
|
||||
rotate(&(game->plr), &(new));
|
||||
if (!i || i == size - 1)
|
||||
draw_pixel(&game->map_img, new.x, new.y, border);
|
||||
else if (!j || j == size - 1)
|
||||
draw_pixel(&game->map_img, new.x, new.y, border);
|
||||
else
|
||||
draw_pixel(&game->map_img, new.x, new.y, fill);
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_map(t_game *game)
|
||||
{
|
||||
t_coord incr;
|
||||
t_coord pos;
|
||||
int cell;
|
||||
|
||||
cell = game->map.cell;
|
||||
incr.x = 0;
|
||||
pos.x = 0;
|
||||
pos.y = 0;
|
||||
while ((game->map.content)[incr.x])
|
||||
{
|
||||
incr.y = 0;
|
||||
while ((game->map.content)[incr.x][incr.y])
|
||||
{
|
||||
if ((game->map.content)[incr.x][incr.y] == '1' )
|
||||
draw_square(game, pos, 0x00999999, 0x00000000, cell, 0);
|
||||
else
|
||||
draw_square(game, pos, 0x00555555, 0x00333333, cell, 0);
|
||||
(incr.y)++;
|
||||
pos.x += cell;
|
||||
}
|
||||
(incr.x)++;
|
||||
pos.x = 0;
|
||||
pos.y += cell;
|
||||
}
|
||||
pos.x = game->plr.pos.x - cell / 2;
|
||||
pos.y = game->plr.pos.y - cell / 2;
|
||||
draw_square(game, pos, 0x00999900, 0x00330033, cell, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
static void draw_screen(t_game *game, t_rcast *rcast)
|
||||
{
|
||||
t_vec screen;
|
||||
|
||||
// draw screen size
|
||||
screen.start.x = rcast->screen_size.start.x + game->plr.pos.x;
|
||||
screen.start.y = rcast->screen_size.start.y + game->plr.pos.y;
|
||||
rotate(&(game->plr), &(screen.start));
|
||||
screen.end.x = rcast->screen_size.end.x + game->plr.pos.x;
|
||||
screen.end.y = rcast->screen_size.end.y + game->plr.pos.y;
|
||||
rotate(&(game->plr), &(screen.end));
|
||||
draw_line(&game->map_img, &screen, 0x00FFFFFF);
|
||||
// draw screen dist
|
||||
screen.start.x = rcast->screen_dist.start.x + game->plr.pos.x;
|
||||
screen.start.y = rcast->screen_dist.start.y + game->plr.pos.y;
|
||||
screen.end.x = rcast->screen_dist.end.x + game->plr.pos.x;
|
||||
screen.end.y = rcast->screen_dist.end.y + game->plr.pos.y;
|
||||
rotate(&(game->plr), &(screen.end));
|
||||
draw_line(&game->map_img, &screen, 0x00FFFFFF);
|
||||
}
|
||||
*/
|
||||
// tmp end
|
||||
|
||||
void draw(t_game *game)
|
||||
{
|
||||
// tmp, to draw map
|
||||
draw_map(game);
|
||||
// tmp end
|
||||
|
||||
raycast(game, &(game->rcast));
|
||||
|
||||
// tmp, to draw map
|
||||
// draw_screen(game, &(game->rcast));
|
||||
mlx_put_image_to_window(game->mlx_ptr, game->map_win.ptr, game->map_img.ptr, 0, SCREEN_HEIGHT);
|
||||
// tmp end
|
||||
|
||||
mlx_put_image_to_window(game->mlx_ptr, game->win.ptr, game->img.ptr, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1,35 +1,5 @@
|
||||
#include "cube3d.h"
|
||||
|
||||
// tmp, to draw rays
|
||||
static void calcul_ray_end(t_rcast *rcast, t_vec *ray)
|
||||
{
|
||||
if (rcast->is_x)
|
||||
{
|
||||
ray->end.x = rcast->cell_x * rcast->cell;
|
||||
if (rcast->ray_sign_x == 1)
|
||||
ray->end.x += rcast->cell;
|
||||
if (rcast->slope_x)
|
||||
{
|
||||
rcast->ratio = (double)(ray->end.x - ray->start.x);
|
||||
rcast->ratio /= (double)rcast->slope_x;
|
||||
ray->end.y = ray->start.y + (double)rcast->slope_y * rcast->ratio;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ray->end.y = rcast->cell_y * rcast->cell;
|
||||
if (rcast->ray_sign_y == 1)
|
||||
ray->end.y += rcast->cell;
|
||||
if (rcast->slope_y)
|
||||
{
|
||||
rcast->ratio = (double)(ray->end.y - ray->start.y);
|
||||
rcast->ratio /= (double)rcast->slope_y;
|
||||
ray->end.x = ray->start.x + (double)rcast->slope_x * rcast->ratio;
|
||||
}
|
||||
}
|
||||
}
|
||||
// tmp end
|
||||
|
||||
static void fill_wall_vector(t_rcast *rcast, int height)
|
||||
{
|
||||
if (height < 0)
|
||||
@@ -51,17 +21,13 @@ static void calcul_wall(t_rcast *rcast)
|
||||
delta = rcast->next_x - rcast->ray_step_x;
|
||||
else if (rcast->is_x == 0)
|
||||
delta = rcast->next_y - rcast->ray_step_y;
|
||||
if (rcast->ray_nb % 10) printf("delta:%i ", delta);
|
||||
height = rcast->screen_height * rcast->cell;
|
||||
if (rcast->slope_x)
|
||||
height *= rcast->slope_x;
|
||||
if (rcast->ray_nb % 10) printf("height:%li ", height);
|
||||
if (rcast->slope_y)
|
||||
height *= rcast->slope_y;
|
||||
if (rcast->ray_nb % 10) printf("height:%li ", height);
|
||||
if (delta && rcast->screen_dist)
|
||||
height /= (delta * rcast->screen_dist);
|
||||
if (rcast->ray_nb % 10) printf("height:%li\n", height);
|
||||
height = ft_abs(height);
|
||||
fill_wall_vector(rcast, height);
|
||||
}
|
||||
@@ -71,16 +37,9 @@ void raycast(t_game *game, t_rcast *rcast)
|
||||
t_vec ray;
|
||||
|
||||
rcast->ray_nb = 0;
|
||||
printf("\n");
|
||||
while (rcast->ray_nb <= rcast->screen_width)
|
||||
{
|
||||
ray_intersect(game, rcast, &ray);
|
||||
|
||||
// tmp, to draw the map
|
||||
calcul_ray_end(rcast, &ray);
|
||||
draw_line(&game->map_img, &ray, 0x00FF00FF);
|
||||
// tmp end
|
||||
|
||||
calcul_wall(rcast);
|
||||
draw_column(game, rcast);
|
||||
(rcast->ray_nb)++;
|
||||
|
||||
@@ -82,17 +82,11 @@ void init_game(t_game *game)
|
||||
// init connexion to server
|
||||
game->mlx_ptr = mlx_init();
|
||||
mb_add(game->mlx_ptr);
|
||||
|
||||
// tmp draw map
|
||||
game->map_win.size_x = game->map.size_x * CELL;
|
||||
game->map_win.size_y = game->map.size_y * CELL + SCREEN_HEIGHT;
|
||||
game->map_win.ptr = mlx_new_window(game->mlx_ptr, game->map_win.size_x, game->map_win.size_y, "map");
|
||||
init_img(&(game->map_img), game->mlx_ptr, &(game->map_win));
|
||||
// tmp end
|
||||
|
||||
// reate window
|
||||
game->win.size_x = SCREEN_WIDTH;
|
||||
game->win.size_y = SCREEN_HEIGHT;
|
||||
game->win.ptr = mlx_new_window(game->mlx_ptr, game->win.size_x, game->win.size_y, "cub3d");
|
||||
// create img
|
||||
init_img(&(game->img), game->mlx_ptr, &(game->win));
|
||||
// k(ey)_hook is the array containing the values of key press events
|
||||
ft_bzero(&game->k_hook, sizeof(game->k_hook));
|
||||
|
||||
@@ -18,8 +18,8 @@ int plr_out_limits(t_game *game, int x, int y)
|
||||
int cell_x;
|
||||
int cell_y;
|
||||
|
||||
xmax = game->map_img.szl / (game->map_img.bpp / 8);
|
||||
ymax = game->map_win.size_y;
|
||||
xmax = game->map.size_x * game->map.cell;
|
||||
ymax = game->map.size_y * game->map.cell;
|
||||
cell_x = x / game->map.cell;
|
||||
cell_y = y / game->map.cell;
|
||||
if (is_wall(game, cell_x, cell_y))
|
||||
|
||||
Reference in New Issue
Block a user