fixings and improvements
dev: - add documentation - main() is more readable fix: - unmanaged errors: - map parsing: error if color value is >255 - map parsing: load_textures(): check return value of xml_xpm_file_to_image() - main.c: draw_screen(): check return value of mlx_new_image() other details: - dev: color_from_rgb(): change signature - fix: nullize map in map_destroy - change: change error message for read_all_text() errors - change: change rotation speed - change: add and use contant NOOBONUS_SPEED
This commit is contained in:
parent
f3da11b105
commit
424b9aa7b2
18 changed files with 135 additions and 47 deletions
|
|
@ -18,9 +18,11 @@
|
|||
# define PI 3.1415926535 // it's just pi
|
||||
|
||||
# define FPS 30 // Number of frames per second (bonus only)
|
||||
# define NOBONUS_SPEED 500 // Number of calls to timedloop for one frame
|
||||
// (mandatory only)
|
||||
|
||||
# define MOVE_SPEED 0.1 // Player oves by N cases by tick
|
||||
# define ROT_SPEED_DIVIDE_PI 48 // Player turns by pi/N rad by tick
|
||||
# define ROT_SPEED_DIVIDE_PI 32 // Player turns by pi/N rad by tick
|
||||
# define MOUSE_ROTATION_SPEED 0.001 // Rotation speed from mouse: rad/px
|
||||
# define HITBOX 0.25 // Hitbox of N cases around player.
|
||||
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ typedef struct s_map
|
|||
} t_map;
|
||||
|
||||
/// @brief Create a t_map from the content of a .cub file.
|
||||
/// If error, write an error text.
|
||||
///
|
||||
/// @param dest Pointer to the t_map to set.
|
||||
/// @param file .cub file to use to create the t_map.
|
||||
|
|
@ -122,12 +123,14 @@ bool map_from_file(t_map *dest, const char *file);
|
|||
void map_destroy(t_map *map);
|
||||
|
||||
/// @brief Return true if the map is valid. Write an error message on stderr.
|
||||
/// If error, write an error text.
|
||||
///
|
||||
/// @param map The map to check.
|
||||
/// @return true if the map is valid, false if not.
|
||||
bool check_map(const t_map *map);
|
||||
|
||||
/// @brief Get a case of the map from its coordinates.
|
||||
/// If x or y are outside the map, undefined behaviour.
|
||||
///
|
||||
/// @param map Map to get the case from.
|
||||
/// @param x x position of the case to return.
|
||||
|
|
|
|||
|
|
@ -35,13 +35,14 @@ typedef struct s_stream
|
|||
void read_expected_string(const char *str, t_stream *stream, bool *err);
|
||||
|
||||
/// @brief Read an unsigned int (which fits the pattern /[0-9]+/).
|
||||
/// It must be between 0 and 255.
|
||||
/// Skip the potential blank space before the string.
|
||||
///
|
||||
/// @param dest Will be set to the value of the unsigned integer.
|
||||
/// @param stream Stream to use.
|
||||
/// @param err Set to true if an error occured.
|
||||
/// If already true, the function won't do anything.
|
||||
void read_unsigned(unsigned int *dest, t_stream *stream, bool *err);
|
||||
void read_unsigned_max_255(unsigned int *dest, t_stream *stream, bool *err);
|
||||
|
||||
/// @brief Read a string until limit char or \0.
|
||||
/// Skip the potential blank space before the string.
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ typedef __u32 t_color;
|
|||
/// @param green Level of green from 0 to 255.
|
||||
/// @param blue Level of blue from 0 to 255.
|
||||
/// @return The result.
|
||||
t_color color_from_rgb(int red, int green, int blue);
|
||||
t_color color_from_rgb(u_int8_t red, u_int8_t green, u_int8_t blue);
|
||||
|
||||
/// @brief Write an error message on stderr.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue