From 11b1b0c29b3911c04a7d784ac9c0c352851be2c9 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 21 Oct 2015 08:49:20 -0400 Subject: documentation part 3 --- include/common.h | 94 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 28 deletions(-) (limited to 'include/common.h') diff --git a/include/common.h b/include/common.h index 183b1cb..d5f1456 100644 --- a/include/common.h +++ b/include/common.h @@ -1,63 +1,101 @@ #ifndef COMMON_H #define COMMON_H -///THIS FILE IS USED FOR VARIABLES THAT WILL BE ACCESED BY MULTIPLE CLASSES/FILES +/* + * Include basic C/C++ facilities +*/ #include +#include #include #include -#include -#include + +/* + * Include GLEW and the SDL 2 headers +*/ + #include + +#include #include #include #include -typedef struct { float x; float y; }vec2; +/* + * Create a basic 2-point structure for coordinate saving +*/ -enum _TYPE { //these are the main types of entities - STRUCTURET = -1, - PLAYERT = 0, - NPCT = 1, - MOBT = 2 -}; +typedef struct { + float x; + float y; +} vec2; -enum GENDER{ - MALE, - FEMALE, - NONE -}; - -#include -#include +/* + * Define the game's name (displayed in the window title), + * the desired window dimensions, + * and whether or not we want the window to be fullscreen. +*/ #define GAME_NAME "Independent Study v.0.2 alpha" #define SCREEN_WIDTH 1280 #define SCREEN_HEIGHT 720 + //#define FULLSCREEN -#define HLINE 3 //base unit of the world +/* + * Define the length of a single HLINE. + * + * The game has a great amount of elements that need to be drawn or detected, and having each + * of them use specific hard-coded numbers would be painful to debug. As a solution, this + * definition was made. Every item being drawn to the screen and most object detection/physic + * handling is done based off of this number. Increasing it will give the game a zoomed-in + * feel, while decreasing it will do the opposite. + * +*/ + +#define HLINE 3 // 3 as in 3 pixels + +/* + * Define 'our' random number generation library. Eventually these macros will be replaced + * with actual functions. + * +*/ #define initRand(s) srand(s) #define getRand() rand() +/* + * At the bottom of this header is the prototype for DEBUG_prints, which writes a formatted + * string to the console containing the callee's file and line number. This macro simplifies + * it to a simple printf call. + * + * DEBUG must be defined for this macro to function. + * +*/ + #define DEBUG_printf( message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__ ) -template //this fuction returns the size of any array -int eAmt(T (&)[N]){return N;} +/* + * References the variable in main.cpp, used for smoother drawing. +*/ -extern bool gameRunning; extern unsigned int deltaTime; -extern unsigned int loops; -extern FILE* config; -extern FILE* names; - -extern Mix_Music *music; -extern Mix_Chunk *horn; +/* + * Loads an image from the given file path and attempts to make a texture out of it. The + * resulting GLuint is returned (used to recall the texture in glBindTexture). + * +*/ GLuint loadTexture(const char *fileName); + +/* + * Prints a formatted debug message to the console, along with the callee's file and line + * number. + * +*/ + void DEBUG_prints(const char* file, int line, const char *s,...); #endif // COMMON_H -- cgit v1.2.3