update stuff
This commit is contained in:
parent
5973022688
commit
544ed8b045
194 changed files with 2060 additions and 1464 deletions
|
|
@ -18,7 +18,6 @@
|
|||
# include "me/vec2/vec2.h"
|
||||
# include "me/blx/sprite.h"
|
||||
# include "me/blx/inputs.h"
|
||||
# include "me/blx/points.h"
|
||||
# include "me/types.h"
|
||||
|
||||
typedef struct s_blx t_blx;
|
||||
|
|
@ -61,20 +60,77 @@ typedef struct s_blx
|
|||
t_blx_data _data;
|
||||
} t_blx;
|
||||
|
||||
/// @brief The main loop function
|
||||
/// @param ctx the BLX context
|
||||
/// @note this is the function that will be called every frame
|
||||
/// @note this is an internal function, you should not call it yourself
|
||||
int blx_loop_func(t_blx *ctx);
|
||||
/// @brief Initialize the BLX context
|
||||
/// @param func the main loop function
|
||||
/// @param free_fn the free function
|
||||
/// @param data the application data
|
||||
/// @return
|
||||
t_blx blx_initialize(t_run_function func,
|
||||
t_free_function free_fn, t_blx_app data);
|
||||
|
||||
/// @brief Draw a sprite onto the screen
|
||||
/// @param app The blx context
|
||||
/// @param pos The position to draw the sprite at
|
||||
/// @param spr The sprite to draw
|
||||
void draw_sprite(t_blx *app, t_vi2d pos,
|
||||
t_sprite *spr);
|
||||
|
||||
/// @brief is the key pressed
|
||||
/// @param ctx the BLX context
|
||||
/// @param input the key to check
|
||||
/// @return true if the key is pressed, false otherwise
|
||||
bool is_key_pressed(t_blx *ctx, t_keysym input);
|
||||
|
||||
|
||||
/// @brief is the key held
|
||||
/// @param ctx the BLX context
|
||||
/// @param input the key to check
|
||||
/// @return true if the key is held, false otherwise
|
||||
bool is_key_held(t_blx *ctx, t_keysym input);
|
||||
|
||||
|
||||
/// @brief is the key released
|
||||
/// @param ctx the BLX context
|
||||
/// @param input the key to check
|
||||
/// @return true if the key is released, false otherwise
|
||||
bool is_key_released(t_blx *ctx, t_keysym input);
|
||||
|
||||
/// @brief Start the game
|
||||
/// @param app the BLX context
|
||||
void blx_run(t_blx app);
|
||||
|
||||
/// @brief Free the game
|
||||
/// @param app the BLX context
|
||||
void blx_free(t_blx app);
|
||||
|
||||
/// @brief Draw a pixel onto the screen
|
||||
/// @param app the BLX context
|
||||
/// @param pos the position to draw the pixel at
|
||||
/// @param col the color of the pixel
|
||||
void blx_draw(t_blx *app, t_vi2d pos, t_color col);
|
||||
|
||||
/// @brief Clear the screen with a color
|
||||
/// @param app the BLX context
|
||||
/// @param col the color to clear the screen with
|
||||
void blx_clear(t_blx *app, t_color col);
|
||||
|
||||
/// @brief Draw a sprite onto another sprite
|
||||
/// @param dest the sprite to be drawn onto
|
||||
/// @param pos the position to draw the sprite at
|
||||
/// @param source the sprite to draw
|
||||
void sprite_draw_onto(t_sprite *dest, t_vi2d pos,
|
||||
t_sprite *source);
|
||||
|
||||
/// @brief Draw a string onto the screen
|
||||
/// @param app the BLX context
|
||||
/// @param pos the position to draw the string at
|
||||
/// @param s the string to draw
|
||||
/// @param col the color of the string
|
||||
void blx_draw_string(t_blx *app, t_vi2d pos,
|
||||
t_const_str s, t_color col);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,21 @@
|
|||
# include "me/blx/blx_key.h"
|
||||
# include "me/types.h"
|
||||
|
||||
/// @brief Handle a key press event
|
||||
/// @param keysym the key that was pressed
|
||||
/// @param ctx the BLX context
|
||||
/// @note this is an internal function, you should not call it yourself
|
||||
int blx_key_pressed_handler(t_keysym keysym, t_blx *ctx);
|
||||
|
||||
/// @brief Handle a key released event
|
||||
/// @param keysym the key that was released
|
||||
/// @param ctx the BLX context
|
||||
/// @note this is an internal function, you should not call it yourself
|
||||
int blx_key_released_handler(t_keysym keysym, t_blx *ctx);
|
||||
|
||||
/// @brief Handle a exit event
|
||||
/// @param ctx the BLX context
|
||||
/// @note this is an internal function, you should not call it yourself
|
||||
int blx_key_exit_handler(t_blx *ctx);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -166,10 +166,34 @@ typedef enum e_keysym
|
|||
|
||||
typedef struct s_blx t_blx;
|
||||
|
||||
/// @brief Convert a keysym to a bit index
|
||||
/// @param key the keysym to convert
|
||||
/// @return the bit index
|
||||
/// @note this is an internal function, you should not call it yourself
|
||||
t_usize keysym_to_bit_index(t_keysym key);
|
||||
|
||||
/// @brief Get a key from a key storage
|
||||
/// @param key_storage the key storage
|
||||
/// @param keysym the key to get
|
||||
/// @return true if the key is present in the storage, false otherwise
|
||||
bool get_key(t_vec_u8 *key_storage, t_keysym keysym);
|
||||
|
||||
/// @brief is the key pressed
|
||||
/// @param ctx The BLX context
|
||||
/// @param key the key to check
|
||||
/// @return true if the key is pressed, false otherwise
|
||||
bool is_key_pressed(t_blx *ctx, t_keysym key);
|
||||
|
||||
/// @brief is the key held
|
||||
/// @param ctx The BLX context
|
||||
/// @param key the key to check
|
||||
/// @return true if the key is held, false otherwise
|
||||
bool is_key_held(t_blx *ctx, t_keysym key);
|
||||
|
||||
/// @brief is the key released
|
||||
/// @param ctx The BLX context
|
||||
/// @param key the key to check
|
||||
/// @return true if the key is released, false otherwise
|
||||
bool is_key_released(t_blx *ctx, t_keysym key);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,7 +23,19 @@ typedef __attribute__((aligned(4))) struct s_color
|
|||
t_u8 a;
|
||||
} t_color;
|
||||
|
||||
/// @brief Create a new color with an specified alpha channel
|
||||
/// @param r the red channel
|
||||
/// @param g the green channel
|
||||
/// @param b the blue channel
|
||||
/// @param alpha the alpha channel
|
||||
/// @return the resulting color
|
||||
t_color new_color_with_alpha(t_u8 r, t_u8 g, t_u8 b, t_u8 alpha);
|
||||
|
||||
/// @brief Create a new color
|
||||
/// @param r the red channel
|
||||
/// @param g the green channel
|
||||
/// @param b the blue channel
|
||||
/// @return the resulting color
|
||||
t_color new_color(t_u8 r, t_u8 g, t_u8 b);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ typedef struct s_blx_input
|
|||
|
||||
} t_blx_input;
|
||||
|
||||
/// @brief Create an input manager
|
||||
/// @param ctx the BLX context
|
||||
/// @return the created input manager
|
||||
/// @note this is an internal function, you should not call it yourself
|
||||
t_blx_input create_inputs_manager(t_blx *ctx);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* points.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/13 17:47:17 by maiboyer #+# #+# */
|
||||
/* Updated: 2023/12/13 18:14:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef POINTS_H
|
||||
# define POINTS_H
|
||||
|
||||
# include "me/types.h"
|
||||
|
||||
typedef struct s_point
|
||||
{
|
||||
t_i32 x;
|
||||
t_i32 y;
|
||||
} t_point;
|
||||
|
||||
#endif
|
||||
|
|
@ -35,19 +35,63 @@ typedef struct s_sprite
|
|||
bool big_endian;
|
||||
} t_sprite;
|
||||
|
||||
bool blx_sprite_from_xpm(t_blx *ctx, t_str path,
|
||||
/// @brief Create a sprite from an XPM file
|
||||
/// @param ctx the BLX context
|
||||
/// @param path the path to the XPM file
|
||||
/// @param[out] out the output sprite
|
||||
/// @return true if an error occured, false otherwise
|
||||
t_error blx_sprite_from_xpm(t_blx *ctx, t_str path,
|
||||
t_sprite *out);
|
||||
bool blx_sprite_new(t_blx *ctx, t_i32 width, t_i32 height,
|
||||
|
||||
/// @brief Create a new sprite
|
||||
/// @param ctx the BLX context
|
||||
/// @param width the width of the sprite in pixels
|
||||
/// @param height the height of the sprite in pixels
|
||||
/// @param out[out] the output sprite
|
||||
/// @return true if an error occured, false otherwise
|
||||
t_error blx_sprite_new(t_blx *ctx, t_i32 width, t_i32 height,
|
||||
t_sprite *out);
|
||||
/// @brief Free a sprite
|
||||
/// @param img the sprite to free
|
||||
void blx_sprite_free(t_sprite img);
|
||||
/// @brief Draw a sprite at a position onto the screen
|
||||
/// @param ctx the BLX context
|
||||
/// @param pos the position to draw the sprite at
|
||||
/// @param img the sprite to draw
|
||||
void blx_draw_sprite_raw(t_blx *ctx, t_vi2d pos,
|
||||
t_sprite *img);
|
||||
|
||||
/// @brief Draw a pixel onto the sprite
|
||||
/// @param img the sprite to draw onto
|
||||
/// @param pos the position to draw the pixel at
|
||||
/// @param col the color of the pixel
|
||||
void sprite_draw(t_sprite *img, t_vi2d pos, t_color col);
|
||||
|
||||
/// @brief Clear a sprite with a color
|
||||
/// @param img the sprite to clear
|
||||
/// @param col the color to clear the sprite with
|
||||
void sprite_clear(t_sprite *img, t_color col);
|
||||
bool sprite_get_pixel(t_sprite *spr, t_vi2d pos,
|
||||
|
||||
/// @brief Get the color of a pixel on a sprite
|
||||
/// @param spr the sprite to get the pixel from
|
||||
/// @param pos the position of the pixel
|
||||
/// @param[out] out the color of the pixel
|
||||
/// @return true if an error occured, false otherwise
|
||||
t_error sprite_get_pixel(t_sprite *spr, t_vi2d pos,
|
||||
t_color *out);
|
||||
|
||||
/// @brief Draw a sprite onto another sprite
|
||||
/// @param dest The sprite to be drawn onto
|
||||
/// @param pos The position to draw the sprite at
|
||||
/// @param source The sprite to draw
|
||||
void sprite_draw_onto(t_sprite *dest, t_vi2d pos,
|
||||
t_sprite *source);
|
||||
|
||||
/// @brief Draw a string onto a sprite
|
||||
/// @param spr The sprite to draw onto
|
||||
/// @param pos The position to draw the string at
|
||||
/// @param sText The string to draw
|
||||
/// @param col The color of the string
|
||||
void sprite_draw_string(t_sprite *spr, t_vi2d pos,
|
||||
t_const_str sText, t_color col);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue