feat: snas can move!!!!!1!
This commit is contained in:
parent
4bd12ffcf1
commit
ef0941e44f
17 changed files with 296 additions and 58 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/29 17:43:01 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/13 15:43:09 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/03/28 15:09:30 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -84,7 +84,8 @@ typedef enum e_direction
|
|||
DOWN,
|
||||
UP,
|
||||
LEFT,
|
||||
RIGHT
|
||||
RIGHT,
|
||||
NO_DIRECTION
|
||||
} t_direction;
|
||||
|
||||
# define OBJECT_SNAS OBJECT_SNAS_DOWN
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/11 15:56:31 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/15 18:49:12 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/03/29 13:55:24 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,7 +15,13 @@
|
|||
|
||||
# include "data_assets.h"
|
||||
|
||||
# define NB_SPRITES 3
|
||||
# define NB_SPRITES 7
|
||||
|
||||
typedef enum e_assettype
|
||||
{
|
||||
ANIMATION, // loops through all the sprites
|
||||
CHARACTER_STILL, // down up left and right positions
|
||||
} t_assettype;
|
||||
|
||||
typedef struct s_spriteinfo
|
||||
{
|
||||
|
|
@ -23,6 +29,7 @@ typedef struct s_spriteinfo
|
|||
int nb_frames;
|
||||
int origin_x;
|
||||
int origin_y;
|
||||
t_assettype type;
|
||||
} t_spriteinfo;
|
||||
|
||||
extern const t_spriteinfo g_spritesmap[NB_SPRITES];
|
||||
|
|
@ -31,7 +38,11 @@ typedef enum e_spriteid
|
|||
{
|
||||
CASE_WALL,
|
||||
CASE_FLOOR,
|
||||
SPR_SNAS_DOWN
|
||||
SPR_SNAS,
|
||||
SPR_SNAS_DOWN,
|
||||
SPR_SNAS_UP,
|
||||
SPR_SNAS_LEFT,
|
||||
SPR_SNAS_RIGHT,
|
||||
} t_spriteid;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/26 15:26:13 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/26 15:48:24 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/03/28 12:50:14 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,7 +19,8 @@
|
|||
# define WINDOW_WIDTH 600
|
||||
# define WINDOW_HEIGHT 400
|
||||
# define WINDOW_TITLE "undretale"
|
||||
# define FPS 10
|
||||
# define FPS 20
|
||||
# define WALK_STEPS_NB 4
|
||||
|
||||
typedef struct s_env
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/15 14:58:25 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/15 20:06:45 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/03/28 17:51:55 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
# include "display.h"
|
||||
# include "sprite.h"
|
||||
|
||||
/**** OBJECT ****/
|
||||
typedef struct s_object t_object;
|
||||
|
||||
typedef struct s_objecttype
|
||||
|
|
@ -31,16 +32,39 @@ typedef struct s_object
|
|||
{
|
||||
t_objecttype type;
|
||||
void *data;
|
||||
} t_object;
|
||||
|
||||
typedef struct s_snas_data
|
||||
{
|
||||
t_direction direction;
|
||||
t_sprite spr;
|
||||
} t_snas_data;
|
||||
} t_object;
|
||||
|
||||
typedef t_object (*t_object_init)(t_memclass);
|
||||
|
||||
t_object snas_init(t_memclass mc);
|
||||
/**** CHARACTER ****/
|
||||
typedef struct s_character_sprites
|
||||
{
|
||||
t_spriteid still;
|
||||
t_spriteid walk_left;
|
||||
t_spriteid walk_right;
|
||||
t_spriteid walk_up;
|
||||
t_spriteid walk_down;
|
||||
} t_character_sprites;
|
||||
|
||||
typedef struct s_character
|
||||
{
|
||||
t_direction direction;
|
||||
t_sprite spr;
|
||||
int walk_remaining_steps;
|
||||
t_character_sprites *sprites;
|
||||
} t_character;
|
||||
|
||||
void character_draw(t_character *character, int x, int y);
|
||||
t_point character_loop(t_character *character, t_point pos,
|
||||
t_direction (*brain)(void));
|
||||
t_character character_init(t_character_sprites *sprites);
|
||||
|
||||
/**** SNAS ****/
|
||||
typedef struct s_snas_data
|
||||
{
|
||||
t_character character;
|
||||
} t_snas_data;
|
||||
|
||||
t_object snas_init(t_memclass mc);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,22 +6,24 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/15 15:05:03 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/15 19:38:46 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/03/27 18:22:51 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef POINT_H
|
||||
# define POINT_H
|
||||
|
||||
# include "data_assets.h"
|
||||
|
||||
typedef struct s_point
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} t_point;
|
||||
|
||||
/*
|
||||
t_point point_init(int x, int y);
|
||||
void point_addto(t_point *dest, t_point src);
|
||||
*/
|
||||
t_point point_fromdirection(t_direction direction);
|
||||
t_point point_multiply(t_point point, int x);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/07 23:00:45 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/15 18:51:14 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/03/26 16:06:02 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -35,6 +35,8 @@ typedef struct s_roomcase
|
|||
|
||||
t_room room_fromfile(t_const_string path);
|
||||
|
||||
void room_loop(t_room room);
|
||||
|
||||
void room_draw(t_room room);
|
||||
|
||||
void room_free(t_room room);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/13 16:34:01 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/13 16:46:44 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/03/28 17:54:32 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,5 +19,7 @@
|
|||
int getlinelen(t_const_string line);
|
||||
void room_getsize(t_memclass mc, t_room *r, t_const_string path);
|
||||
t_roomcase *getroomcase(t_const_string path, char c);
|
||||
void moveobject(t_room room, t_point start, t_point move);
|
||||
bool isinlist(void *addr, t_list list);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/07 22:13:20 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/03/15 19:55:46 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/03/28 15:59:30 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -18,12 +18,14 @@
|
|||
|
||||
typedef struct s_sprite
|
||||
{
|
||||
const t_spriteinfo *info;
|
||||
int index;
|
||||
} t_sprite;
|
||||
t_spriteinfo *info;
|
||||
int index;
|
||||
} t_sprite;
|
||||
|
||||
t_sprite sprite_init(t_spriteid spr);
|
||||
|
||||
void sprite_draw(int x, int y, t_sprite *spr);
|
||||
|
||||
void sprite_character_set_direction(t_sprite *spr, t_direction value);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue