Mini map - sarahmss/Cub3d GitHub Wiki
before we start 3D raycasting, we must know how our map looks. Besides that, move in 2D plane is quite easier than in 3D. So for, to draw a mini map first we have to parse it and converts in a int matrix. Given a map, we can put it in a int **cub_map
with height and width. To see this as a 2D plane we can represent each element
of matrix as square with
.
To draw it using minilibx we will draw a square in a img using brasenham to draw lines.
void render_map(int **cub_map, int w, int h, t_image *img)
typedef struct s_player
{
t_point pos;
double radius;
double rotation_angle;
int move_speed;
double rotation_speed;
} t_player;
Now we have a map rendered we can put a player in game. Here we will draw a circle with minilibx puting pixels based in circuference formula where
corresponds to the position of N, S, W or E given in .cub file. Besides that, we can also draw a vector direction which indicates for where our player is moving for.
where
it is the rotation angle.
To update player position we must know in each direction we are moving. This info is stored in double rotation_angle
whcih can decrease or increase as fast as double rotation_speed
- Calculate the number of rays