Dumb-ways-to-memorize
2D game
Macros | Functions | Variables
game.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SCREEN_RES_X   1280
 
#define SCREEN_RES_Y   720
 
#define JSON_FILE   "GameData.json"
 
#define ENTITY_FILE   "Entities.json"
 
#define SPLASH_SCREEN   "SplashScreen"
 
#define LEVELS_NOT_DEFAULT   "LevelsPerGame"
 
#define LIVES_DEFAULT   3
 
#define LEVELS_DEFAULT   6
 

Functions

int Setup ()
 
int Run ()
 
void Shutdown ()
 

Variables

int mState
 

Macro Definition Documentation

#define ENTITY_FILE   "Entities.json"

Definition at line 8 of file game.h.

#define JSON_FILE   "GameData.json"

Definition at line 7 of file game.h.

Referenced by LoadGameData().

#define LEVELS_DEFAULT   6

Definition at line 12 of file game.h.

Referenced by LoadLevelData().

#define LEVELS_NOT_DEFAULT   "LevelsPerGame"

Definition at line 10 of file game.h.

Referenced by LoadLevelData().

#define LIVES_DEFAULT   3

Definition at line 11 of file game.h.

#define SCREEN_RES_X   1280

Definition at line 4 of file game.h.

#define SCREEN_RES_Y   720

Definition at line 5 of file game.h.

#define SPLASH_SCREEN   "SplashScreen"

Definition at line 9 of file game.h.

Referenced by Update().

Function Documentation

int Run ( )

Runs the main game loop.

Returns
An int.
Author
Anthony Rios
Date
3/29/2016

Definition at line 666 of file game.c.

References Draw(), exitRequest, FRAME_DELAY, gCurrentTime, gDelay, Poll(), and Update().

Referenced by main().

667 {
668  while(!exitRequest)
669  {
670  Poll();
671  Update();
672  Draw();
673  gDelay = SDL_GetTicks() - gCurrentTime;
674  SDL_Delay(gDelay > FRAME_DELAY ? 0 : gDelay);
675  }
676  return 0;
677 }
int gDelay
Definition: game.c:23
unsigned int gCurrentTime
Definition: game.c:50
void Poll()
Definition: game.c:427
#define FRAME_DELAY
Definition: globals.h:135
int exitRequest
Definition: game.c:22
void Update()
Definition: game.c:458
void Draw()
Definition: game.c:547
int Setup ( )

Loads files and images for game.

Returns
state returns 0 on success, -1 on error
Author
Anthony Rios
Date
1/31/2016

Definition at line 592 of file game.c.

References gController, InitAISystem(), InitEntitySystem(), InitGraphics(), InitMenuSystem(), LoadEntityData(), LoadGameData(), LoadLevelData(), LoadMenuData(), LoadPowerUpData(), and SelectLevels().

Referenced by main().

593 {
594  //sprite_t *test_sprite;
595  //vec2_t test_vec = {0,0};
596  srand(SDL_GetTicks());
597  //atexit(Shutdown);
598 
599  if(LoadGameData())
600  {
601  perror("Loading game data went wrong");
602  return -1;
603  }
604  if(InitGraphics())
605  {
606  perror("Initializing entity system went wrong");
607  return -1;
608  }
609  if(InitEntitySystem())
610  {
611  perror("Initializing entity system went wrong");
612  return -1;
613  }
614  if(InitMenuSystem())
615  {
616  perror("Initialize Menu system went wrong");
617  return -1;
618  }
619  if(InitAISystem())
620  {
621  perror("Initialize AI system went wrong");
622  return -1;
623  }
624  if(LoadEntityData())
625  {
626  perror("Loading entity data went wrong");
627  return -1;
628  }
629  if(LoadMenuData())
630  {
631  perror("Shit Happens");
632  return -1;
633  }
634  if(LoadLevelData())
635  {
636  perror("Loading level data went wrong");
637  return -1;
638  }
639  if(LoadPowerUpData())
640  {
641  perror("Loading entity data went wrong");
642  return -1;
643  }
644  if(SelectLevels())
645  {
646  perror("Selecting levels went wrong");
647  return -1;
648  }
649  gController = SDL_GameControllerOpen(0);
650  //PrintObject(gLevelObject, gLevelData);
651  //test_sprite = LoadSprite("Sprite/UI/NESController.png",0);
652  //test_sprite->mCurrentFrame = LoadAnimation(test_sprite->mSize.x, test_sprite->mSize.y, test_sprite->mSize.x, test_sprite->mSize.y);
653  //FreeSprite(test_sprite);
654 
655  return 0;
656 }
int LoadMenuData()
Definition: game.c:250
int LoadGameData()
Definition: game.c:60
SDL_GameController * gController
Definition: game.c:48
int InitGraphics()
Definition: graphics.c:19
int InitEntitySystem()
Definition: entity.c:217
int LoadEntityData()
Definition: game.c:96
int LoadLevelData()
Definition: game.c:148
int SelectLevels()
Definition: game.c:297
int InitAISystem()
Definition: ai_interpret.c:646
int LoadPowerUpData()
Definition: game.c:196
void Shutdown ( )

Definition at line 679 of file game.c.

Referenced by main().

680 {
681 
682  return;
683 }

Variable Documentation

int mState

Definition at line 14 of file game.h.