feat: engine finished (i think)

This commit is contained in:
mcolonna 2024-03-15 20:01:38 +01:00
parent 8076487071
commit 3abc6cbfd6
15 changed files with 207 additions and 41 deletions

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/11 15:56:31 by mcolonna #+# #+# */
/* Updated: 2024/03/11 16:31:33 by mcolonna ### ########.fr */
/* Updated: 2024/03/15 18:49:12 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,7 +15,7 @@
# include "data_assets.h"
# define NB_SPRITES 2
# define NB_SPRITES 3
typedef struct s_spriteinfo
{
@ -30,7 +30,8 @@ extern const t_spriteinfo g_spritesmap[NB_SPRITES];
typedef enum e_spriteid
{
CASE_WALL,
CASE_FLOOR
CASE_FLOOR,
SPR_SNAS_DOWN
} t_spriteid;
#endif

46
includes/object.h Normal file
View file

@ -0,0 +1,46 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* object.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/15 14:58:25 by mcolonna #+# #+# */
/* Updated: 2024/03/15 20:06:45 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef OBJECT_H
# define OBJECT_H
# include "point.h"
# include "data_assets.h"
# include "libtf.h"
# include "display.h"
# include "sprite.h"
typedef struct s_object t_object;
typedef struct s_objecttype
{
t_point (*loop)(t_object *, t_point pos);
void (*draw)(t_object *, int x, int y);
} t_objecttype;
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;
typedef t_object (*t_object_init)(t_memclass);
t_object snas_init(t_memclass mc);
#endif

27
includes/point.h Normal file
View file

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* point.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/15 15:05:03 by mcolonna #+# #+# */
/* Updated: 2024/03/15 19:38:46 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef POINT_H
# define POINT_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);
*/
#endif

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/07 23:00:45 by mcolonna #+# #+# */
/* Updated: 2024/03/13 14:11:13 by mcolonna ### ########.fr */
/* Updated: 2024/03/15 18:51:14 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,11 +15,7 @@
# include "sprite.h"
# include "libtf.h"
typedef struct s_object
{
t_sprite spr;
} t_object;
# include "object.h"
typedef struct s_room
{
@ -32,9 +28,10 @@ typedef struct s_room
typedef struct s_roomcase
{
char c;
t_spriteid surface_spr;
} t_roomcase;
char c;
t_spriteid surface_spr;
t_object_init object;
} t_roomcase;
t_room room_fromfile(t_const_string path);

View file

@ -6,7 +6,7 @@
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/07 22:13:20 by mcolonna #+# #+# */
/* Updated: 2024/03/11 16:26:48 by mcolonna ### ########.fr */
/* Updated: 2024/03/15 19:55:46 by mcolonna ### ########.fr */
/* */
/* ************************************************************************** */