Dumb-ways-to-memorize
2D game
|
#include <jsmn.h>
Go to the source code of this file.
Data Structures | |
struct | vec2_t |
struct | KV_Pair_t |
Macros | |
#define | STRING_TYPE(X) |
#define | SIGN_BIT 0xF000 |
#define | HAZARD_NULL 0x0 |
#define | HAZARD_MAX (0x1 >> 31) |
#define | HAZARD_DAMAGE 10 |
#define | HAZARD_STUN_FRAMES 10 |
#define | ENTITIES_FILE_STR "Entities" |
#define | POWER_UPS_STR "PowerUps" |
#define | G_NAME_STR "Name" |
#define | LOC_NAME_STR "name" |
#define | FRAME_DELAY 13 |
#define | PHYSICS_LIMITER 2 |
Typedefs | |
typedef unsigned int | address_t |
Enumerations | |
enum | entity_state_t { ENTITY_STATE_DEAD, ENTITY_STATE_ALIVE, ENTITY_STATE_OTHER } |
enum | collision_type_t { COLLISION_TYPE_STATIC, COLLISION_TYPE_RAGDOLL, COLLISION_TYPE_CLIP } |
enum | menu_item_state_t { MENU_ITEM_STATE_NULL, MENU_ITEM_STATE_SELECTED = 0x1, MENU_ITEM_STATE_NOT_SELECTED = 0x2, MENU_ITEM_STATE_PICKED = 0x4, MENU_ITEM_STATE_MAX = 0x8 } |
enum | animation_state_t { ANIMATION_IDLE, ANIMATION_WALK, ANIMATION_JUMP, ANIMATION_ATTACK, ANIMATION_HIT, ANIMATION_MAX = 20 } |
enum | GameState { SPLASH = 0x1, START = 0x2, GUESS = 0x4, CHOOSE = 0x8, PLAYING = 0x10, END = 0x20 } |
Functions | |
void | Vec2Add (vec2_t *A, vec2_t *B, vec2_t *C) |
void | Vec2Subtract (vec2_t *First, vec2_t *Second, vec2_t *C) |
void | Vec2MultiplyScalar (vec2_t *A, int B, vec2_t *C) |
int | LargestDivisor (int num) |
GameState | StrToGameState (char *str) |
int | StrToMenuType (char *str) |
int | StrToHazard (char *str) |
collision_type_t | StrToCollisionType (char *str) |
entity_state_t | StrToEntityState (char *str) |
int | SelectLevels () |
int | LoadSelectedLevel (int level) |
void | RandomizeSelectedLevels () |
int | CountMem (void *src, int size_type) |
int | AllocateDynamic (void **dst, void *src, int size_type, int size) |
int | CompareMemToMemArray (void *mem, void *mem_array, int size_type, int size_array) |
vec2_t * | ParseToVec2 (struct object_s *object, char *str) |
char ** | ParseToStringArray (struct object_s *object, char *str) |
Variables | |
vec2_t | gZeroPos |
GameState | gGameState |
char ** | Hazards_str |
char * | gEntitiesFile |
char * | Collisions_str [] |
char * | EntityStates_str [] |
char * | gPowerUpsFile |
vec2_t * | mousePos |
int * | keyPower |
char ** | gSelectedPowerUps |
char ** | gUsedPowerUps |
char * | gCurrentPowerUpName |
char ** | gLevels |
char ** | gSelectedLevels |
void * | gWorld |
void * | gMouse |
int | gPlayerLives |
int | gLevelsPerGame |
int | gScreenWidth |
int | gScreenHeight |
unsigned int | gCurrentTime |
vec2_t | gGravity |
int | exitRequest |
jsmn_parser | gParser |
jsmntok_t * | gGameTokens |
struct object_s * | gGameObject |
jsmntok_t * | gEntityTokens |
struct object_s * | gEntityObject |
jsmntok_t * | gLevelTokens |
struct object_s * | gLevelObject |
char * | gGameData |
char * | gEntityData |
char * | gLevelData |
#define ENTITIES_FILE_STR "Entities" |
Definition at line 106 of file globals.h.
Referenced by LoadGameData().
#define FRAME_DELAY 13 |
Definition at line 135 of file globals.h.
Referenced by AttackAI(), InitPlayer(), JumpAI(), MoveAI(), NothingAI(), Run(), ThinkGeneric(), TouchGeneric(), TouchPlayer(), and WalkAI().
#define G_NAME_STR "Name" |
Definition at line 133 of file globals.h.
Referenced by LoadLevel().
#define HAZARD_DAMAGE 10 |
Definition at line 100 of file globals.h.
Referenced by TouchGeneric(), and TouchPlayer().
#define HAZARD_STUN_FRAMES 10 |
Definition at line 101 of file globals.h.
Referenced by TouchGeneric(), and TouchPlayer().
#define PHYSICS_LIMITER 2 |
Definition at line 136 of file globals.h.
Referenced by RunPhysics().
#define POWER_UPS_STR "PowerUps" |
Definition at line 114 of file globals.h.
Referenced by LoadGameData().
#define STRING_TYPE | ( | X | ) |
enum animation_state_t |
Defines an enum for animation states in mSprites array
enum collision_type_t |
Defines the enum which are the collision types for the physics engine
enum entity_state_t |
Defines the enum relating to entity states
enum GameState |
Defines the enum for the game states
enum menu_item_state_t |
Defines the enum for menu item states
int AllocateDynamic | ( | void ** | dst, |
void * | src, | ||
int | size_type, | ||
int | size | ||
) |
Allocate memory and copy over src into it. Adds Null to end. Returns NULL on size 0
[in,out] | dst | If non-null, destination for the allocation. |
[in,out] | src | If non-null, source for the adding. |
size_type | Size of the type. | |
size | The size. |
Definition at line 66 of file mymath.c.
Referenced by CopyObjectToObjectArray(), and ParseToObject().
int CompareMemToMemArray | ( | void * | mem, |
void * | mem_array, | ||
int | size_type, | ||
int | size_array | ||
) |
Compare memory to memory array.
[in,out] | mem | If non-null, the memory. |
[in,out] | mem_array | If non-null, array of memories. |
size_type | Size of type, via sizeof() function. | |
size_array | Size of Array. |
Definition at line 77 of file mymath.c.
Referenced by RandomizeSelectedLevels(), and SelectLevels().
int CountMem | ( | void * | src, |
int | size_type | ||
) |
Counts the memory of type size_type, given that the final address is null.
[in,out] | src | If non-null, source of memory. |
size_type | Size of the type. |
Definition at line 51 of file mymath.c.
Referenced by CopyObjectToObjectArray(), CountObjectChildren(), CountObjectMembers(), DoPlayerThink(), FindKey(), FindMenuItem(), FindPower(), FindValue(), IncrementFrame(), LoadEntityData(), LoadLevel(), LoadLevelData(), LoadMenu(), LoadMenuData(), LoadPowerUpData(), ParseAI(), ParsePresetAI(), ParseToEntity(), ParseToStringArray(), PrintObject(), ProcessMenuItemsByType(), RandomizeSelectedLevels(), StrToHazard(), TouchGeneric(), TouchGoal(), TouchPlayer(), UpdatePowerSelectMenu(), UpdatePowerUpMenu(), and UpdateVerticalMenu().
int LargestDivisor | ( | int | num | ) |
Definition at line 5 of file mymath.c.
Referenced by ProcessMenuItemsByType().
int LoadSelectedLevel | ( | int | level | ) |
Loads selected level.
level | The level. |
Definition at line 390 of file game.c.
References ConvertFileToUseable(), gLevelData, gLevelObject, gSelectedLevels, LoadLevel(), and ParseToObject().
Referenced by UpdatePowerSelectMenu().
char** ParseToStringArray | ( | struct object_s * | object, |
char * | str | ||
) |
Parse obj/data to string array.
[in,out] | object | If non-null, the object. |
[in,out] | str | If non-null, the string. |
Referenced by LoadEntityData(), and LoadLevel().
Parse given obj/str to vector 2.
[in,out] | object | If non-null, the object. |
[in,out] | str | If non-null, the string. |
Referenced by LoadGameData(), LoadLevel(), ParseToEntity(), and SetAI_Action().
void RandomizeSelectedLevels | ( | ) |
Randomize selected levels.
Definition at line 343 of file game.c.
References CompareMemToMemArray(), CountMem(), gLevels, gLevelsPerGame, and gSelectedLevels.
int SelectLevels | ( | ) |
Select the levels randomly from the available levels, stores in gSelectedLevels.
Definition at line 297 of file game.c.
References CompareMemToMemArray(), gLevels, gLevelsPerGame, and gSelectedLevels.
Referenced by Setup().
collision_type_t StrToCollisionType | ( | char * | str | ) |
Converts a string into a entity collision type
Converts a str to a collision type.
[in,out] | str | If non-null, the string. |
Definition at line 344 of file mystrings.c.
References COLLISION_TYPE_CLIP, and Collisions_str.
Referenced by ParseComplexMember().
entity_state_t StrToEntityState | ( | char * | str | ) |
Converts a string into an entity state
Converts a str to an entity state.
[in,out] | str | If non-null, the string. |
Definition at line 370 of file mystrings.c.
References COLLISION_TYPE_CLIP, and EntityStates_str.
Referenced by ParseComplexMember().
GameState StrToGameState | ( | char * | str | ) |
Converts a string into a game state
Converts a str to a game state.
[in,out] | str | If non-null, the string. |
Definition at line 274 of file mystrings.c.
References CHOOSE, END, GAME_STATE_CHOOSE_STR, GAME_STATE_END_STR, GAME_STATE_GUESS_STR, GAME_STATE_PLAYING_STR, GAME_STATE_SPLASH_STR, GAME_STATE_START_STR, GUESS, PLAYING, SPLASH, and START.
Referenced by LoadMenu(), and LoadMenuData().
int StrToHazard | ( | char * | str | ) |
Converts a string into a hazard, using the parsed hazards_str for comparison
Converts a str to a hazard.
[in,out] | str | If non-null, the string. |
Definition at line 317 of file mystrings.c.
References CountMem(), and Hazards_str.
Referenced by ParseComplexMember().
int StrToMenuType | ( | char * | str | ) |
Converts a string into a menu type
Definition at line 697 of file menu.c.
References MENU_TYPE_CHOOSE, MENU_TYPE_GRID, MENU_TYPE_H, MENU_TYPE_NULL, MENU_TYPE_POWER, MENU_TYPE_STR_CHOOSE, MENU_TYPE_STR_GRID, MENU_TYPE_STR_H, MENU_TYPE_STR_POWER, MENU_TYPE_STR_V, and MENU_TYPE_V.
Referenced by LoadMenu().
Definition at line 20 of file mymath.c.
References vec2_t::x, and vec2_t::y.
Referenced by DoCollision(), JumpAI(), MoveAI(), RunPhysics(), Spawn(), and WalkAI().
char* Collisions_str[] |
The collisions type strings for parsing
Definition at line 14 of file entity.c.
Referenced by StrToCollisionType().
char* EntityStates_str[] |
The entity state strings for parsing
Definition at line 15 of file entity.c.
Referenced by StrToEntityState().
int exitRequest |
The integer to be changed to exit
Definition at line 22 of file game.c.
Referenced by DrawChoose(), DrawGuess(), DrawStart(), InitPlayer(), Poll(), Run(), and Update().
char* gCurrentPowerUpName |
The current power up name
Definition at line 43 of file game.c.
Referenced by UpdatePowerSelectMenu().
unsigned int gCurrentTime |
The current time , updated from last update call
Definition at line 50 of file game.c.
Referenced by InitPlayer(), JumpAI(), MoveAI(), NothingAI(), Run(), RunEntities(), ThinkGeneric(), ThinkPlayer(), Update(), and WalkAI().
char* gEntitiesFile |
The name of the entities file
Definition at line 39 of file game.c.
Referenced by LoadEntityData(), and LoadGameData().
char* gEntityData |
The current parsed string of the entity file
Definition at line 37 of file game.c.
Referenced by LoadEntityData().
struct object_s* gEntityObject |
char* gGameData |
Game Data File - holding the contents of file via string
Definition at line 36 of file game.c.
Referenced by LoadEntityData(), LoadGameData(), LoadLevelData(), LoadMenuData(), LoadPowerUpData(), Update(), and UpdatePowerUpMenu().
struct object_s* gGameObject |
The game object
Definition at line 33 of file game.c.
Referenced by LoadEntityData(), LoadGameData(), LoadLevelData(), LoadMenuData(), LoadPowerUpData(), Update(), and UpdatePowerUpMenu().
GameState gGameState |
State of the game
Definition at line 44 of file game.c.
Referenced by Draw(), ThinkPlayer(), TouchGoal(), Update(), UpdatePowerSelectMenu(), UpdatePowerUpMenu(), and UpdateVerticalMenu().
vec2_t gGravity |
The gravity which affects all the assets
Definition at line 7 of file dumb_physics.c.
char* gLevelData |
Information describing the current level
Definition at line 38 of file game.c.
Referenced by LoadSelectedLevel().
struct object_s* gLevelObject |
char** gLevels |
The level names
Definition at line 26 of file game.c.
Referenced by LoadLevelData(), RandomizeSelectedLevels(), and SelectLevels().
int gLevelsPerGame |
The levels per game
Definition at line 24 of file game.c.
Referenced by LoadLevelData(), RandomizeSelectedLevels(), SelectLevels(), and UpdatePowerUpMenu().
void* gMouse |
jsmn_parser gParser |
int gPlayerLives |
The lives of the player
Definition at line 10 of file player.c.
Referenced by DecrementPlayerLives(), InitPlayer(), and ThinkPlayer().
char* gPowerUpsFile |
The name of the power ups file
Definition at line 40 of file game.c.
Referenced by LoadGameData(), and LoadPowerUpData().
int gScreenHeight |
Te set Height of the screen
Definition at line 17 of file graphics.c.
Referenced by ApplyBounds(), InitGraphics(), LoadGameData(), and ProcessMenuItemsByType().
int gScreenWidth |
The set Width of the screen
Definition at line 16 of file graphics.c.
Referenced by ApplyBounds(), InitGraphics(), LoadGameData(), and ProcessMenuItemsByType().
char** gSelectedLevels |
The selected levels to load
Definition at line 27 of file game.c.
Referenced by LoadSelectedLevel(), RandomizeSelectedLevels(), and SelectLevels().
char** gSelectedPowerUps |
The power ups the player selects
Definition at line 28 of file game.c.
Referenced by LoadMenu(), TouchGoal(), UpdatePowerSelectMenu(), and UpdatePowerUpMenu().
char** gUsedPowerUps |
The used power ups for this game run
Definition at line 29 of file game.c.
Referenced by TouchGoal(), UpdatePowerSelectMenu(), and UpdatePowerUpMenu().
void* gWorld |
vec2_t gZeroPos |
Definition at line 46 of file game.c.
Referenced by InitPlayer().
char** Hazards_str |
The hazards string array which is defined in the gamedata file
Definition at line 13 of file entity.c.
Referenced by LoadEntityData(), and StrToHazard().
int* keyPower |
The key press related to using the power
Definition at line 18 of file parsepowerup.c.
Referenced by CallInfo(), and ParseToPowerUp().
vec2_t* mousePos |
The mouse position
Definition at line 17 of file parsepowerup.c.