Dumb-ways-to-memorize
2D game
parseentity.h
Go to the documentation of this file.
1 #ifndef __PARSE_ENTITY_H
2 #define __PARSE_ENTITY_H
3 
4 #include "entity.h"
5 #include "parseobject.h"
6 
7 extern char *ComplexVariableNames[]; /**< The complex variables which need more processing to parse */
8 extern char *Vector2VariableNames[]; /**< The variables which parse to vectors */
9 extern char *SimpleVariableNames[]; /**< The simple variables are there given values*/
10 
11 /** Defines the enum for variables in the entity structure */
12 typedef enum
13 {
14  ENTITY_MEMBER_HAZARDS, /**< An enum constant representing the entity member hazards */
15  ENTITY_MEMBER_COLLISION_TYPE, /**< An enum constant representing the entity member collision type */
16  ENTITY_MEMBER_ENTITY_STATE, /**< An enum constant representing the entity member entity state */
19 
20 /** Defines the enum for variables in the entity struct with vec2_t values */
21 typedef enum
22 {
23  ENTITY_MEMBER_ACCEL, /**< An enum constant representing the entity member accel */
24  ENTITY_MEMBER_VELOCITY, /**< An enum constant representing the entity member velocity */
25  ENTITY_MEMBER_POSITION, /**< An enum constant representing the entity member position */
27 
28 
29 /** Defines the enum for simple members in the entity */
30 typedef enum
31 {
32  ENTITY_MEMBER_SPRITE, /**< An enum constant representing the sprite file names */
33  ENTITY_MEMBER_HEALTH, /**< An enum constant representing the default health of the entity */
34  ENTITY_MEMBER_DAMAGE, /**< An enum constant representing the damage the entity deals on collision */
35  ENTITY_MEMBER_HEIGHT, /**< An enum constant representing the heights of the sprites */
36  ENTITY_MEMBER_WIDTH, /**< An enum constant representing the widths of th sprites */
37  ENTITY_MEMBER_FRAMES /**< An enum constant representing the number of frames in each sprite */
39 
40 /**
41  * Alias for a switch case that handles complex member to entity.
42  *
43  * @param [in,out] ent If non-null, the ent.
44  * @param member The member.
45  * @param [in,out] value If non-null, the value.
46  *
47  * @author Anthony Rios
48  * @date 3/30/2016
49  */
50 void AddComplexMemToEnt(entity_t *ent, entity_members_complex_t member, void *value);
51 
52 /**
53  * Handles entering / converting complex members into the entity given.
54  *
55  * @param [in,out] ent If non-null, the ent.
56  * @param [in,out] token If non-null, the token(s) to parse.
57  * @param [in,out] str If non-null, the global string to parse tokens from.
58  * @param member The complex member associated with values given.
59  * @param size The amount of values to input.
60  *
61  * @author Anthony Rios
62  * @date 3/29/2016
63  */
64 void ParseComplexMember(entity_t *ent, jsmntok_t* token, char *str, entity_members_complex_t member, int size);
65 
66 /**
67  * Adds a vector2 to the entity, which is a switch case similar to AddComplexMemToEnt.
68  *
69  * @param [in,out] ent If non-null, the ent.
70  * @param member The vector member to enters.
71  * @param [in,out] value If non-null, the value of the vector.
72  *
73  * @author Anthony Rios
74  * @date 3/31/2016
75  */
76 void AddVector2Entity(entity_t *ent, entity_members_vector2_t member, vec2_t *value);
77 
78 /**
79  * Loads and adds the sprite files given to the entity.
80  *
81  * @param [in,out] ent If non-null, the ent.
82  * @param [in,out] files If non-null, an array of the strings with file names of the sprites.
83  * @param size The size.
84  *
85  * @author Anthony Rios
86  * @date 3/31/2016
87  */
88 void AddSpritesToEnt(entity_t *ent, char **files, int size);
89 
90 /**
91  * Parse to entity.
92  * Tries to Assign everything , and defaults all function pointers to generic.
93  * Current Frame = 0, Weight = 1
94  *
95  * @param [in,out] object If non-null, the object.
96  * @param [in,out] str If non-null, the string.
97  *
98  * @return null if it fails, else a pointer to an entity_t.
99  *
100  * @author Anthony Rios
101  * @date 3/21/2016
102  */
103 extern entity_t *ParseToEntity(object_t *object, char* str);
104 
105 
106 #endif
Definition: jsmn.h:40
void AddComplexMemToEnt(entity_t *ent, entity_members_complex_t member, void *value)
Definition: parseentity.c:15
entity_members_complex_t
Definition: parseentity.h:12
void AddVector2Entity(entity_t *ent, entity_members_vector2_t member, vec2_t *value)
Definition: parseentity.c:32
char * Vector2VariableNames[]
Definition: parseentity.c:12
void ParseComplexMember(entity_t *ent, jsmntok_t *token, char *str, entity_members_complex_t member, int size)
Definition: parseentity.c:166
void AddSpritesToEnt(entity_t *ent, char **files, int size)
Definition: parseentity.c:49
char * SimpleVariableNames[]
Definition: parseentity.c:13
entity_members_simple_t
Definition: parseentity.h:30
entity_members_vector2_t
Definition: parseentity.h:21
entity_t * ParseToEntity(object_t *object, char *str)
Definition: parseentity.c:70
char * ComplexVariableNames[]
Definition: parseentity.c:11
Definition: globals.h:19