Dumb-ways-to-memorize
2D game
|
Go to the source code of this file.
Data Structures | |
struct | entity_t |
Macros | |
#define | MAX_ENTITIES 250 |
#define | ENTITY_DIR_LEFT 0 |
#define | ENTITY_DIR_RIGHT 1 |
Functions | |
int | InitEntitySystem () |
entity_t * | InitNewEntity () |
entity_t * | FindNextFreeCachePos () |
entity_t * | FindCachedEntity (const char *name) |
entity_t * | FindEntity (const char *name) |
entity_t * | FindFreeEntity (int *position) |
entity_t * | LookForEntityAtPos (vec2_t position) |
int | Distance2Entity (entity_t *self, entity_t *other) |
void | RunEntities () |
void | DrawEntities () |
void | PrintEntity (entity_t *ent) |
void | FreeEntity (entity_t *ent) |
void | FreeNonPlayerEntities () |
void | ShutdownEntitySystem () |
void | DrawGeneric (entity_t *self) |
void | DrawPlayer (entity_t *self) |
void | ThinkGeneric (entity_t *self) |
void | ThinkPlayer (entity_t *self) |
void | ThinkEnemy (entity_t *self) |
void | TouchGeneric (entity_t *self, entity_t *other, int type) |
void | TouchPlayer (entity_t *self, entity_t *other, int type) |
void | TouchEnemy (entity_t *self, entity_t *other, int type) |
void | TouchGoal (entity_t *self, entity_t *other, int type) |
Variables | |
entity_t * | gEntityDictionary |
entity_t * | gEntities |
int | gLastEntity |
void(*)(entity_t *) | GetFunctionAI (ai_function_t *data) |
#define ENTITY_DIR_LEFT 0 |
Definition at line 9 of file entity.h.
Referenced by DoPlayerThink().
#define ENTITY_DIR_RIGHT 1 |
Definition at line 10 of file entity.h.
Referenced by DoPlayerThink(), and Spawn().
#define MAX_ENTITIES 250 |
Definition at line 8 of file entity.h.
Referenced by DrawEntities(), FindCachedEntity(), FindEntity(), FindFreeEntity(), FindNextFreeCachePos(), FreeEntity(), FreeNonPlayerEntities(), InitEntitySystem(), LookForEntityAtPos(), RunEntities(), RunPhysics(), and ShutdownEntitySystem().
int Distance2Entity | ( | entity_t * | self, |
entity_t * | other | ||
) |
Distance 2 entity other from entity self.
[in,out] | self | If non-null, the class instance that this method operates on. |
[in,out] | other | If non-null, the other entity. |
Definition at line 371 of file entity.c.
Referenced by ThinkEnemy().
void DrawEntities | ( | ) |
Draw entities, if they have draw functions.
Definition at line 264 of file entity.c.
References Draw(), gEntities, and MAX_ENTITIES.
Referenced by DrawPlaying().
void DrawGeneric | ( | entity_t * | self | ) |
Draws the entity via self->mAnimation if set, or the first sprite which is idle.
[in,out] | self | If non-null, the class instance that this method operates on. |
Definition at line 17 of file entity.c.
References ANIMATION_IDLE, DrawSprite(), and gRenderer.
Referenced by InitPlayer(), LoadLevel(), and ParseToEntity().
void DrawPlayer | ( | entity_t * | self | ) |
entity_t* FindCachedEntity | ( | const char * | name | ) |
Searches for the cached entity whose name matches given str.
name | The name of the entity. |
Definition at line 301 of file entity.c.
References gEntityDictionary, and MAX_ENTITIES.
Referenced by AttackAI(), InitPlayer(), JumpAI(), LoadLevel(), MoveAI(), NothingAI(), ParseToPowerUp(), and WalkAI().
entity_t* FindEntity | ( | const char * | name | ) |
Searches for the first entity with the name of given str.
name | The name of the searched for entity. |
Definition at line 316 of file entity.c.
References gEntities, and MAX_ENTITIES.
Referenced by ThinkEnemy().
entity_t* FindFreeEntity | ( | int * | position | ) |
Searches for the first free entity.
[in,out] | position | If non-null, the position. |
Definition at line 331 of file entity.c.
References gEntities, gLastEntity, and MAX_ENTITIES.
Referenced by InitNewEntity().
entity_t* FindNextFreeCachePos | ( | ) |
Searches for the next free cache position in gEntitiesDictionary.
Definition at line 250 of file entity.c.
References gEntityDictionary, and MAX_ENTITIES.
Referenced by LoadEntityData().
void FreeEntity | ( | entity_t * | ent | ) |
Free entity.
[in,out] | ent | If non-null, the ent. |
Definition at line 379 of file entity.c.
References gEntities, and MAX_ENTITIES.
Referenced by Destroy(), FreeNonPlayerEntities(), LoadLevel(), ShutdownEntitySystem(), ThinkGeneric(), and ThinkPlayer().
void FreeNonPlayerEntities | ( | ) |
Frees the non player entities, use for Destroy World.
Definition at line 409 of file entity.c.
References FreeEntity(), gEntities, gPlayer, and MAX_ENTITIES.
Referenced by LoadLevel(), and ThinkPlayer().
int InitEntitySystem | ( | ) |
Init entity system.
Definition at line 217 of file entity.c.
References gEntities, gEntityDictionary, gLastEntity, and MAX_ENTITIES.
Referenced by Setup().
entity_t* InitNewEntity | ( | ) |
Init new entity in the memory of global entity space.
Definition at line 235 of file entity.c.
References FindFreeEntity(), gEntities, and gLastEntity.
Referenced by InitPlayer(), LoadLevel(), and Spawn().
entity_t* LookForEntityAtPos | ( | vec2_t | position | ) |
Look for entity at position.
position | The position. |
Definition at line 355 of file entity.c.
References gEntities, MAX_ENTITIES, vec2_t::x, and vec2_t::y.
Referenced by GetAtPoint().
void PrintEntity | ( | entity_t * | ent | ) |
Prints the entities data, used for debug.
[in,out] | ent | If non-null, the ent. |
Definition at line 195 of file parseentity.c.
Referenced by ParseToEntity().
void RunEntities | ( | ) |
Executes the entities think functions.
Definition at line 281 of file entity.c.
References gCurrentTime, gEntities, and MAX_ENTITIES.
Referenced by UpdatePlaying().
void ShutdownEntitySystem | ( | ) |
Shutdown entity system, frees all the entities.
Definition at line 427 of file entity.c.
References FreeEntity(), gEntities, and MAX_ENTITIES.
void ThinkEnemy | ( | entity_t * | self | ) |
The modular think function for enemy entities with an AI.
[in,out] | self | If non-null, the class instance that this method operates on. |
Definition at line 102 of file entity.c.
References AI_FLAG_CHECK_OBJECT, AI_FLAG_CHECK_PLAYER, AI_VAR_CHECK, Distance2Entity(), FindEntity(), GetFunctionAI, and gPlayer.
Referenced by LoadLevel().
void ThinkGeneric | ( | entity_t * | self | ) |
Generic think function, checks health and dies when health <= 0
[in,out] | self | If non-null, the class instance that this method operates on. |
Definition at line 45 of file entity.c.
References FRAME_DELAY, FreeEntity(), and gCurrentTime.
Referenced by ParseToEntity().
void ThinkPlayer | ( | entity_t * | self | ) |
The player think function, handles lives ,gamestate switching , and input.
[in,out] | self | If non-null, the class instance that this method operates on. |
Definition at line 59 of file entity.c.
References BUTTON_NO_INPUT, DoPlayerThink(), FreeEntity(), FreeNonPlayerEntities(), gButtonQ, gController, gCurrentPowerUp, gCurrentTime, gGameState, gPlayer, gPlayerLives, GUESS, PLAYER_LIVES, and START.
Referenced by InitPlayer().
void TouchEnemy | ( | entity_t * | self, |
entity_t * | other, | ||
int | type | ||
) |
The touch function for an enemy, currently does nothing.
[in,out] | self | If non-null, the class instance that this method operates on. |
[in,out] | other | If non-null, the other. |
type | The type. |
Definition at line 196 of file entity.c.
References COLLISION_TYPE_RAGDOLL, and COLLISION_TYPE_STATIC.
void TouchGeneric | ( | entity_t * | self, |
entity_t * | other, | ||
int | type | ||
) |
Generic touch function, Receives pain from touch and inflict pain on touch depending on hazard types.
[in,out] | self | If non-null, the class instance that this method operates on. |
[in,out] | other | If non-null, the other. |
type | The type. |
Definition at line 139 of file entity.c.
References ANIMATION_HIT, COLLISION_TYPE_RAGDOLL, COLLISION_TYPE_STATIC, CountMem(), FRAME_DELAY, HAZARD_DAMAGE, and HAZARD_STUN_FRAMES.
Referenced by LoadLevel(), and ParseToEntity().
void TouchGoal | ( | entity_t * | self, |
entity_t * | other, | ||
int | type | ||
) |
The touch function for the goal entity / flag. Switches gamestate based on if you won or should go to the next level.
[in,out] | self | If non-null, the class instance that this method operates on. |
[in,out] | other | If non-null, the other entity it touched. |
type | The type. |
Definition at line 209 of file entity.c.
References CHOOSE, CountMem(), gGameState, gPlayer, gSelectedPowerUps, gUsedPowerUps, and START.
Referenced by LoadLevel().
void TouchPlayer | ( | entity_t * | self, |
entity_t * | other, | ||
int | type | ||
) |
The player touch function called on collision. If he touches a hazard, he gets damaged.
[in,out] | self | If non-null, the class instance that this method operates on. |
[in,out] | other | If non-null, the other. |
type | The type. |
Definition at line 168 of file entity.c.
References ANIMATION_HIT, COLLISION_TYPE_RAGDOLL, COLLISION_TYPE_STATIC, CountMem(), FRAME_DELAY, HAZARD_DAMAGE, and HAZARD_STUN_FRAMES.
Referenced by InitPlayer().
entity_t* gEntities |
The memory for entities that are currently running in the game
Definition at line 11 of file entity.c.
Referenced by DrawEntities(), FindEntity(), FindFreeEntity(), FreeEntity(), FreeNonPlayerEntities(), GetWorld(), InitEntitySystem(), InitNewEntity(), LookForEntityAtPos(), RunEntities(), RunPhysics(), and ShutdownEntitySystem().
entity_t* gEntityDictionary |
Entities loaded from files AKA cached entities
Definition at line 41 of file game.c.
Referenced by FindCachedEntity(), FindNextFreeCachePos(), and InitEntitySystem().
void(*)(entity_t *) GetFunctionAI(ai_function_t *data) |
Returns a function pointer to the think function, given ai_function data.
[in,out] | parameter1 | If non-null, the first parameter. |
Definition at line 238 of file ai_interpret.c.
Referenced by ThinkEnemy().
int gLastEntity |
The last entity that was free'd or created
Definition at line 12 of file entity.c.
Referenced by FindFreeEntity(), InitEntitySystem(), and InitNewEntity().