Header file for the cub3d project. More...
#include "data_structure.h"#include <stddef.h>#include <stdint.h>#include <unistd.h>#include <sys/time.h>

Go to the source code of this file.
Macros | |
| #define | PI 3.141592653589793238462643383279502884197169399375105820974944592307 |
| PI approximation. | |
| #define | MINIMAP_DEFAULT_VALUE true |
| Enable Minimap by default and can be toggled with the 'M' key. | |
| #define | FIELD_OF_VIEW_DEFAULT_VALUE true |
| Enable Field of View by default and can be toggled with the 'F' key. | |
| #define | COLLISION_DEFAULT_VALUE true |
| Enable Collision by default and can be toggled with the 'C' key. | |
| #define | ENABLE_FILTERS true |
| Enable Filters features. | |
| #define | MOUSE_SENSITIVITY_FACTOR 0.001f |
| Value used to define the sensitivity of the mouse. This value is multiplied by the delta mouse x to get the turn amount. A higher value will make the mouse more sensitive and will turn faster. Anything higher or lower than 0.001f will be strange. | |
| #define | MOVEMENT_SPEED_TURNING 0.015f |
| Value used to define the turning speed of the player. This value is multiplied by the input to get the turn amount. A higher value will make the player turn faster. | |
| #define | MOVEMENT_SPEED_FWD_BWD 0.025f |
| Value used to define the movement speed of the player in forward or backward. This value is multiplied by the input to get the amount. A higher value will make the player walk faster. | |
| #define | MOVEMENT_SPEED_LEFT_RIGHT 0.015f |
| Value used to define the movement speed of the player when moving left or right. This value is multiplied by the input to get the amount. A higher value will make the player walk faster. | |
| #define | MINIMAP_PLAYER_COLOR 0xffffff00 |
| #define | MINIMAP_PLAYER_LINE_SIGHT_COLOR 0xffffff00 |
| #define | MINIMAP_PLAYER_CONE_SIGHT_COLOR 0xffffaaaa |
| #define | MINIMAP_FLOOR_COLOR 0xff000000 |
| #define | MINIMAP_WALL_COLOR 0xffffffff |
| #define | MINIMAP_KEY_COLOR 0xffffff00 |
| #define | MINIMAP_DOOR_COLOR 0xff0000ff |
| #define | MINIMAP_NUM_TILES_X 15 |
| Number of tiles on X axis. | |
| #define | MINIMAP_NUM_TILES_Y 15 |
| Number of tiles on Y axis. | |
| #define | MINIMAP_TILE_SIZE 16 |
| #define | MINIMAP_TILES_X 15 |
| #define | MINIMAP_TILES_Y 15 |
| #define | MINIMAP_PLAYER_SIZE 4 |
| #define | MINIMAP_LINE_OF_SIGHT_FACTOR 2 |
| #define | DEBUG_PRINT_KEYCODE 0 |
| Enable to print key presses. | |
| #define | DEBUG_PRINT_FPS 0 |
| Enable if you want to see the FPS. | |
| #define | DEBUG_FPS_REFRESH 0 |
| Enable to keep the FPS counter on a single line. | |
| #define | DEBUG_PRINT_TEXTURE_SWAP 0 |
| Enable printing of message to indicate texture swapping. | |
| #define | DEBUG_PRINT_TEXTURE_ALTERED 0 |
| Enable printing message when a texture is altered with filters. | |
| #define | CROSS_APPLY_SETTINGS 0 |
| Enable if closing the settings window should behave as 'Enter'. | |
| #define | ESCAPE_APPLY_SETTINGS 0 |
| Enable pressing Esc in the settings menu should behave as 'Enter'. | |
Functions | |
| int | cub3d (int argc, char **argv) |
| Main function of the cub3d project. | |
| int | cub_read_args (int argc, char **argv, t_args *args) |
| Reads and verifies the arguments passed to the program. | |
| char ** | fill_config_region (t_map *map) |
| Fill the config region of the file. | |
| char ** | fill_map_region (t_map *map) |
| Fill the map region of the file. | |
| char ** | read_file_lines (t_map *map, char *map_name) |
| Read the map file line by line and return an array of strings. | |
| size_t | count_file_lines (char *file_name) |
| Simple function to count the number of lines in a file. | |
| void | ft_exit (t_mlx mlx, t_map *map) |
| Exit the program. | |
| int | ft_mlx_init (t_data *data) |
| Initialize the mlx structure, create settings window, and load game. | |
| void | ft_mlx_end (t_mlx *mlx) |
| Close and free the mlx structure. | |
| void * | ft_settings (t_mlx *mlx) |
| Generate the window settings for the program. | |
| enum e_screen_size | circle_state (int x, int y) |
| Return an enum according to selected circle using coordinates. | |
| int | ft_set_screen_size (t_mlx *mlx, enum e_screen_size size) |
| Set screen size according to an enum. | |
| void | ft_free_settings (t_mlx *mlx) |
| Free all the settings variables. | |
| void | settings_hooks (t_data *data) |
| Set the settings hooks on the settings window. | |
| void | state_machine (int keycode, t_mlx *mlx) |
| State machine for the settings window. | |
| int | cub_keydown_hook (int keycode, void *param) |
| Hook when a key is pressed. | |
| int | cub_keyup_hook (int keycode, void *param) |
| Hook when a key is released. | |
| int | cub_mouse_click_hook (int button, int x, int y, void *param) |
| Hook when the mouse is moved while clicking. | |
| int | cub_mouse_hook (int x, int y, void *param) |
| Hook when the mouse is moved. | |
| int | hook_settings_handle_mouse_click (int button, int x, int y, void *param) |
| Hook when the mouse is moved while clicking for the settings. | |
| int | hook_settings_handle_mouse_motion (int x, int y, void *param) |
| Hook when the mouse is moved for the settings. | |
| int | hook_settings_close_window (void *param) |
| Hook used to close window or set the window size if MACRO Enabled. | |
| int | hook_settings_handle_keypress (int keycode, void *param) |
| Handle mouse click in the settings window. | |
| t_map | ft_map_check_dimensions (t_map *map, char *map_name) |
| Check the map structure and try to open the map file. sets error to -1 if an error occurred. | |
| t_map | ft_check_config (t_map *map) |
| Check if the config is properly formatted or not. | |
| t_map | ft_check_floor_ceiling (t_map *map) |
| Check the floor and ceiling colors. | |
| size_t | is_config_line (char *line) |
| Return a positive number if a config line is detected. | |
| t_map | check_map_chars_borders (t_map *map) |
| Check if the map has only acceptable characters and if there is borders everywhere, as it should be. | |
| t_coordinates | find_position (t_map *map, const char *charset) |
| Find the position of the player with charset in the map. | |
| int | validate_map (t_map *map) |
| Validate if the map has unclosed holes or an unfinished outer layer. | |
| bool | is_only_whitespace (const char *str) |
| Check if the string contains only whitespace characters. | |
| void | suppress_newlines (char **lines) |
| Suppress newlines in the given lines. | |
| int | is_walkable (char c) |
| Check if a character is walkable or not. | |
| int | is_in_bounds (char **map, size_t y, size_t x) |
| Check if a position is in bounds of map or not. | |
| int | safe_open (char *file_name) |
| Try to open the map file specified by map_name. | |
| int | safe_close (int *fd) |
| Close safely the file descriptor Modify the file descriptor to -1 after closing it. | |
| int | try_to_open_close_file (char *file_name) |
| Try to open the file specified by file_name. | |
| size_t | count_array_length (char **array) |
| Count the number of strings that an array have Should absolutely be NULL-Terminated. | |
| void | ft_free_all (t_data *data) |
| Free all the memory allocated for the data structure. | |
| void | ft_free_file (t_map *map) |
| Free the strings of the file. | |
| void | ft_free_textures (t_mlx *mlx, t_textures *textures) |
| Free all the textures stored in mlx structure and map struct. | |
| void | ft_free_textures_path (t_map *map) |
| Free the path (name) of the textures in memory. | |
| void | ft_free_map (t_map_raoul *map) |
| Free the map structure. | |
| uint64_t | get_time_ms (void) |
| Get time in milliseconds. | |
| uint64_t | timeval_to_us (const struct timeval *tv) |
| Convert a timeval in microseconds. | |
| uint16_t | count_fps (bool print) |
| Count the FPS and print it to the console. It will print the FPS every second if DEBUG_PRINT_FPS is set to 1. | |
Header file for the cub3d project.
Contains all function prototypes used in the project.