gamedev
Macros | Functions | Variables
main.cpp File Reference

The file that links everything together for the game to run. The main game loop contains all of the global variables the game uses, and it runs the main game loop, the render loop, and the logic loop that control all of the entities. More...

#include <cstdio>
#include <chrono>
#include <common.h>
#include <world.h>
#include <ui.h>
#include <entities.h>

Macros

#define TICKS_PER_SEC   20
 
#define MSEC_PER_TICK   (1000/TICKS_PER_SEC)
 

Functions

void initEverything (void)
 
void logic (void)
 
void render (void)
 
void mainLoop (void)
 
std::string readFile (const char *filePath)
 
unsigned int millis (void)
 
int main ()
 

Variables

SDL_Window * window = NULL
 
SDL_GLContext mainGLContext = NULL
 
GLuint bgDay
 
GLuint bgNight
 
GLuint bgMtn
 
GLuint bgTreesFront
 
GLuint bgTreesMid
 
GLuint bgTreesFar
 
GLuint invUI
 
bool gameRunning
 
float handAngle
 
WorldcurrentWorld =NULL
 
Playerplayer
 
bool worldInside
 
unsigned int tickCount = 0
 
unsigned int deltaTime = 0
 
GLuint fragShader
 
GLuint shaderProgram
 
FILE * names
 
unsigned int loops = 0
 
vec2 offset
 
WEATHER weather
 
bool fadeEnable
 

Detailed Description

The file that links everything together for the game to run. The main game loop contains all of the global variables the game uses, and it runs the main game loop, the render loop, and the logic loop that control all of the entities.

Function Documentation

int main ( )

(Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually make openGL calls. Exit if there was an error.

` (Attempt to) Initialize SDL_image libraries with IMG_INIT_PNG so that we can load PNG textures for the entities and stuff.

(Attempt to) Initialize SDL_mixer libraries for loading and playing music/sound files.

unsigned int millis ( void  )

millis

We've encountered many problems when attempting to create delays for triggering the logic function. As a result, we decided on using the timing libraries given by <chrono> in the standard C++ library. This function simply returns the amount of milliseconds that have passed sine the epoch.