Dumb-ways-to-memorize
2D game
|
#include "globals.h"
#include "player_controller.h"
#include "game.h"
#include "entity.h"
#include "mystrings.h"
#include "parseobject.h"
#include "parseentity.h"
#include "parsepowerup.h"
#include "parselevel.h"
#include "dumb_physics.h"
#include "player.h"
#include "graphics.h"
#include <SDL.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "menu.h"
Go to the source code of this file.
Functions | |
int | LoadGameData () |
int | LoadEntityData () |
int | LoadLevelData () |
int | LoadPowerUpData () |
int | LoadMenuData () |
int | SelectLevels () |
void | RandomizeSelectedLevels () |
int | LoadSelectedLevel (int level) |
void | Poll () |
void | UpdatePlaying () |
void | Update () |
void | DrawSplash () |
void | DrawStart () |
void | DrawGuess () |
void | DrawChoose () |
void | DrawPlaying () |
void | Draw () |
int | Setup () |
int | Run () |
void | Shutdown () |
Variables | |
int | exitRequest = 0 |
int | gDelay = 0 |
int | gLevelsPerGame = LEVELS_DEFAULT |
jsmn_parser | gParser |
char ** | gLevels = NULL |
char ** | gSelectedLevels = NULL |
char ** | gSelectedPowerUps = NULL |
char ** | gUsedPowerUps = NULL |
jsmntok_t * | gGameTokens |
jsmntok_t * | gEntityTokens |
jsmntok_t * | gLevelTokens |
object_t * | gGameObject |
object_t * | gEntityObject |
object_t * | gLevelObject |
char * | gGameData |
char * | gEntityData |
char * | gLevelData |
char * | gEntitiesFile = NULL |
char * | gPowerUpsFile = NULL |
entity_t * | gEntityDictionary |
power_t * | gPowerUps |
char * | gCurrentPowerUpName = NULL |
GameState | gGameState = SPLASH |
sprite_t * | gSplash = NULL |
vec2_t | gZeroPos = {0,0} |
SDL_Event | gEventQ |
SDL_GameController * | gController = NULL |
SDL_GameControllerButton | gButtonQ |
unsigned int | gCurrentTime = 0 |
void Draw | ( | ) |
Definition at line 547 of file game.c.
References CHOOSE, DrawChoose(), DrawGuess(), DrawPlaying(), DrawSplash(), DrawStart(), gGameState, gRenderer, GUESS, PLAYING, SPLASH, and START.
Referenced by DrawEntities(), and Run().
void DrawChoose | ( | ) |
void DrawGuess | ( | ) |
void DrawPlaying | ( | ) |
Draws the main game state, which is playing the game.
Definition at line 763 of file game.c.
References DrawEntities(), and DrawLevel().
Referenced by Draw(), and Update().
void DrawSplash | ( | ) |
Draws the splash screen.
Definition at line 691 of file game.c.
References DrawSprite(), gRenderer, and gSplash.
Referenced by Draw(), and Update().
void DrawStart | ( | ) |
int LoadEntityData | ( | ) |
Definition at line 96 of file game.c.
References ConvertFileToUseable(), CountMem(), FindKey(), FindNextFreeCachePos(), FindObject(), gEntitiesFile, gEntityData, gEntityObject, gGameData, gGameObject, Hazards_str, ParseToEntity(), ParseToObject(), ParseToStringArray(), and PrintObject().
Referenced by Setup().
int LoadGameData | ( | ) |
Loads game data from GameData.json, stored in gGameData.
Definition at line 60 of file game.c.
References ConvertFileToUseable(), ENTITIES_FILE_STR, FindObject(), gEntitiesFile, gGameData, gGameObject, gPowerUpsFile, gScreenHeight, gScreenWidth, JsmnToString(), JSON_FILE, ParseToObject(), ParseToVec2(), POWER_UPS_STR, PrintObject(), SCREEN_STRING, vec2_t::x, and vec2_t::y.
Referenced by Setup().
int LoadLevelData | ( | ) |
Loads level file names, and how many levels per game.
Definition at line 148 of file game.c.
References CountMem(), FindKey(), FindObject(), gGameData, gGameObject, gLevels, gLevelsPerGame, JsmnToInt(), JsmnToString(), LEVELS_DEFAULT, and LEVELS_NOT_DEFAULT.
Referenced by Setup().
int LoadMenuData | ( | ) |
Loads menu data, from files given, which are put in gMenus
Definition at line 250 of file game.c.
References ConvertFileToUseable(), CountMem(), FindObject(), FindValue(), gGameData, gGameObject, gMenus, InitMenuSystem(), JsmnToString(), LoadMenu(), ParseToObject(), PrintObject(), START, and StrToGameState().
Referenced by Setup().
int LoadPowerUpData | ( | ) |
After Load GameData, Before Menu. Loads the power_ups in the file given.
Definition at line 196 of file game.c.
References ConvertFileToUseable(), CountMem(), FindObject(), gGameData, gGameObject, gPowerUps, gPowerUpsFile, JsmnToString(), ParseToObject(), and ParseToPowerUp().
Referenced by Setup().
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().
void Poll | ( | ) |
Polls for all events and handles them.
Definition at line 427 of file game.c.
References BUTTON_NO_INPUT, exitRequest, gButtonQ, gController, gEventQ, and UpdatePlaying().
Referenced by Run().
void RandomizeSelectedLevels | ( | ) |
Randomize selected levels.
Definition at line 343 of file game.c.
References CompareMemToMemArray(), CountMem(), gLevels, gLevelsPerGame, and gSelectedLevels.
int Run | ( | ) |
Runs the main game loop.
Definition at line 666 of file game.c.
References Draw(), exitRequest, FRAME_DELAY, gCurrentTime, gDelay, Poll(), and Update().
Referenced by main().
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().
int Setup | ( | ) |
Loads files and images for game.
Definition at line 592 of file game.c.
References gController, InitAISystem(), InitEntitySystem(), InitGraphics(), InitMenuSystem(), LoadEntityData(), LoadGameData(), LoadLevelData(), LoadMenuData(), LoadPowerUpData(), and SelectLevels().
Referenced by main().
void Shutdown | ( | ) |
void Update | ( | ) |
Definition at line 458 of file game.c.
References CHOOSE, DrawChoose(), DrawGuess(), DrawPlaying(), DrawSplash(), DrawStart(), exitRequest, FindValue(), gButtonQ, gCurrentTime, gGameData, gGameObject, gGameState, gMenus, gSplash, GUESS, LoadSprite(), PLAYING, SPLASH, SPLASH_SCREEN, START, and UpdatePlaying().
Referenced by FindMenuFromGameState(), and Run().
void UpdatePlaying | ( | ) |
Updates the playing game state.
Definition at line 776 of file game.c.
References RunEntities(), and RunPhysics().
int exitRequest = 0 |
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().
SDL_GameControllerButton gButtonQ |
The button qeueu updated with the current button pressed
Definition at line 49 of file game.c.
Referenced by Poll(), ThinkPlayer(), and Update().
SDL_GameController* gController = NULL |
The controller
Definition at line 48 of file game.c.
Referenced by Poll(), Setup(), and ThinkPlayer().
char* gCurrentPowerUpName = NULL |
The current power up name
Definition at line 43 of file game.c.
Referenced by UpdatePowerSelectMenu().
unsigned int gCurrentTime = 0 |
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 = NULL |
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().
entity_t* gEntityDictionary |
Entities loaded from files AKA cached entities
Definition at line 41 of file game.c.
Referenced by FindCachedEntity(), FindNextFreeCachePos(), and InitEntitySystem().
object_t* gEntityObject |
SDL_Event gEventQ |
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().
object_t* gGameObject |
The game object
Definition at line 33 of file game.c.
Referenced by LoadEntityData(), LoadGameData(), LoadLevelData(), LoadMenuData(), LoadPowerUpData(), Update(), and UpdatePowerUpMenu().
State of the game
Definition at line 44 of file game.c.
Referenced by Draw(), ThinkPlayer(), TouchGoal(), Update(), UpdatePowerSelectMenu(), UpdatePowerUpMenu(), and UpdateVerticalMenu().
char* gLevelData |
Information describing the current level
Definition at line 38 of file game.c.
Referenced by LoadSelectedLevel().
object_t* gLevelObject |
char** gLevels = NULL |
The level names
Definition at line 26 of file game.c.
Referenced by LoadLevelData(), RandomizeSelectedLevels(), and SelectLevels().
int gLevelsPerGame = LEVELS_DEFAULT |
The levels per game
Definition at line 24 of file game.c.
Referenced by LoadLevelData(), RandomizeSelectedLevels(), SelectLevels(), and UpdatePowerUpMenu().
jsmn_parser gParser |
power_t* gPowerUps |
The loaded power ups
Definition at line 42 of file game.c.
Referenced by FindPower(), InitPlayer(), LoadPowerUpData(), and UpdatePowerUpMenu().
char* gPowerUpsFile = NULL |
The name of the power ups file
Definition at line 40 of file game.c.
Referenced by LoadGameData(), and LoadPowerUpData().
char** gSelectedLevels = NULL |
The selected levels to load
Definition at line 27 of file game.c.
Referenced by LoadSelectedLevel(), RandomizeSelectedLevels(), and SelectLevels().
char** gSelectedPowerUps = NULL |
The power ups the player selects
Definition at line 28 of file game.c.
Referenced by LoadMenu(), TouchGoal(), UpdatePowerSelectMenu(), and UpdatePowerUpMenu().
sprite_t* gSplash = NULL |
The splash screen sprite
Definition at line 45 of file game.c.
Referenced by DrawSplash(), and Update().
char** gUsedPowerUps = NULL |
The used power ups for this game run
Definition at line 29 of file game.c.
Referenced by TouchGoal(), UpdatePowerSelectMenu(), and UpdatePowerUpMenu().
vec2_t gZeroPos = {0,0} |
Definition at line 46 of file game.c.
Referenced by InitPlayer().