feat: add some ketchup *

also fix the 4th ketchup still image
This commit is contained in:
mcolonna 2024-04-03 14:49:35 +02:00
parent a7deecf072
commit ea59cdd8a6
22 changed files with 733 additions and 556 deletions

View file

@ -6,28 +6,30 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/11 15:56:31 by mcolonna #+# #+# */
/* Updated: 2024/04/02 17:38:37 by mcolonna ### ########.fr */
/* Updated: 2024/04/03 15:53:40 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef DATA_SPRITES_H
# define DATA_SPRITES_H
# define NB_SPRITES 9
# define NB_SPRITES 11
typedef enum e_spritetype
{
ANIMATION, // loops through all the sprites
ANIMATION_ONCE, // loops through all the sprites but only once
CHARACTER_STILL, // down up left and right positions
} t_spritetype;
typedef struct s_spritemeta
{
t_assetsmap_id first_frame;
int nb_frames;
int origin_x;
int origin_y;
t_spritetype type;
int nb_frames;
int delay_frame;
} t_spritemeta;
extern const t_spritemeta g_spritesmap[NB_SPRITES];
@ -43,6 +45,8 @@ typedef enum e_spritesmap_id
SPR_SNAS_LEFT,
SPR_SNAS_RIGHT,
SPR_WALL,
SPR_KETCHUP,
SPR_KETCHUP_FADE,
} t_spritesmap_id;
#endif

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/07 22:13:20 by mcolonna #+# #+# */
/* Updated: 2024/04/02 17:37:12 by mcolonna ### ########.fr */
/* Updated: 2024/04/03 15:56:22 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,7 +21,8 @@ typedef struct s_sprite
t_sprite sprite_init(t_spritesmap_id spr);
void sprite_draw(int x, int y, t_sprite *spr);
// Return false only if the image drawn was the last (end of the animation).
bool sprite_draw(int x, int y, t_sprite *spr);
void sprite_character_set_direction(t_sprite *spr, t_direction value);

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/02 13:53:41 by mcolonna #+# #+# */
/* Updated: 2024/04/02 18:26:03 by mcolonna ### ########.fr */
/* Updated: 2024/04/03 15:56:53 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -35,6 +35,7 @@
# include "display/display.h"
# include "display/sprite.h"
# include "room/visual.h"
# include "room/object.h"
# include "room/character.h"
# include "room/objects.h"

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/26 15:26:13 by mcolonna #+# #+# */
/* Updated: 2024/04/02 14:39:26 by mcolonna ### ########.fr */
/* Updated: 2024/04/03 16:06:13 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,6 +26,7 @@ typedef struct s_env
void *win;
t_room room;
bool input[4];
int ketchup;
} t_env;
extern t_env g_env;

View file

@ -6,28 +6,32 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/15 14:58:25 by mcolonna #+# #+# */
/* Updated: 2024/04/02 17:49:28 by mcolonna ### ########.fr */
/* Updated: 2024/04/03 16:11:55 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef OBJECT_H
# define OBJECT_H
typedef struct s_object t_object;
typedef struct s_object t_object;
typedef struct s_character t_character;
typedef struct s_objecttype
{
t_point (*loop)(t_object *, t_point pos);
void (*draw)(t_object *, int x, int y);
} t_objecttype;
t_point (*loop)(t_object *, t_point pos);
void (*draw)(t_object *, int x, int y);
// Called when a character want to walk through this object.
// Returns false to block the character. If true, it will pass.
// If walk_through is NULL, the character is blocked.
bool (*walk_through)(t_character *, t_point pos);
} t_objecttype;
typedef struct s_object
{
t_objecttype type;
void *data;
bool solid;
} t_object;
typedef t_object (*t_object_init)(t_memclass);
typedef t_object (*t_object_init)(t_memclass);
#endif

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/02 17:47:01 by mcolonna #+# #+# */
/* Updated: 2024/04/02 17:48:38 by mcolonna ### ########.fr */
/* Updated: 2024/04/03 15:25:31 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -29,4 +29,12 @@ typedef struct s_wall_data
t_object wall_init(t_memclass mc);
// KETCHUP
typedef struct s_ketchup_data
{
t_sprite spr;
} t_ketchup_data;
t_object ketchup_init(t_memclass mc);
#endif

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/07 23:00:45 by mcolonna #+# #+# */
/* Updated: 2024/04/02 17:50:58 by mcolonna ### ########.fr */
/* Updated: 2024/04/03 15:32:23 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,6 +19,7 @@ typedef struct s_room
int height;
t_sprite *surfaces;
t_object **objects;
t_visual **visuals;
t_memclass mc;
} t_room;

24
includes/room/visual.h Normal file
View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* visual.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/03 15:34:18 by mcolonna #+# #+# */
/* Updated: 2024/04/03 15:51:14 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef VISUAL_H
# define VISUAL_H
typedef struct s_visual
{
t_sprite spr;
} t_visual;
void visual_loop(t_visual **visual, int x, int y);
void visual_addtoroom(t_spritesmap_id sprid, t_point pos);
#endif