diff options
Diffstat (limited to 'include/common.h')
-rw-r--r-- | include/common.h | 139 |
1 files changed, 82 insertions, 57 deletions
diff --git a/include/common.h b/include/common.h index 52daf4b..f8bd935 100644 --- a/include/common.h +++ b/include/common.h @@ -1,19 +1,19 @@ +/** @file common.h + * @brief Common items needed by most other files. + * + * This file contains headers, variables and functions that are needed in + * most other files included in this project. + */ + #ifndef COMMON_H #define COMMON_H -/* - * Include basic C/C++ facilities -*/ - #include <iostream> #include <cstdlib> #include <vector> #include <math.h> -#include <thread> - -/* - * Include GLEW and the SDL 2 headers -*/ +#include <string> +#include <fstream> #define GLEW_STATIC #include <GL/glew.h> @@ -22,9 +22,6 @@ #include <SDL2/SDL_opengl.h> #include <SDL2/SDL_image.h> #include <SDL2/SDL_mixer.h> -#include <string> -#include <fstream> - #ifdef __WIN32__ typedef unsigned int uint; @@ -33,100 +30,128 @@ typedef unsigned int uint; #include <Texture.h> -/* - * This flag lets the compiler know that we are using shaders -*/ +/** + * This flag lets the compiler know that we want to use shaders. + */ #define SHADERSs -/* - * Create a basic 2-point structure for coordinate saving -*/ +/** + * This structure contains a set of coordinates for ease of coding. + */ typedef struct { float x; float y; } vec2; +/** + * This structure contains two sets of coordinates for ray drawing. + */ + typedef struct { vec2 start; vec2 end; } Ray; -/* - * 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 the game's name (displayed in the window title). + */ #define GAME_NAME "Independent Study v.0.4 alpha" +/** + * The desired width of the game window. + */ + #define SCREEN_WIDTH 1280 + +/** + * The desired height of the game window. + */ + #define SCREEN_HEIGHT 720 //#define FULLSCREEN -/* - * Define the length of a single HLINE. +/** + * 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. * - * 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 HLINE 3 -/* - * Define 'our' random number generation library. Eventually these macros will be replaced - * with actual functions. - * -*/ +/** + * A 'wrapper' for libc's srand(), as we hope to eventually have our own random number + * generator. + */ #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. +/** + * A 'wrapper' for libc's rand(), as we hope to eventually have our own random number + * generator. + */ + +#define getRand() rand() + +/** + * Included in common.h is a 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__ ) +/** + * Defines pi for calculations that need it. + */ #define PI 3.1415926535 -/* - * References the variable in main.cpp, used for smoother drawing. -*/ +/** + * References the variable in main.cpp, used for smoother drawing. + */ extern unsigned int deltaTime; -/* - * References the variable in main.cpp, used for drawing with the player -*/ +/** + * References the variable in main.cpp, used for drawing with the player. + */ + extern vec2 offset; -extern float handAngle; - +/** + * Counts the number of times logic() (see main.cpp) has been called, for animating + * sprites. + */ extern unsigned int loops; -/* +/** * 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,...); +/** + * Sets color using glColor3ub(), but handles potential overflow. + */ + void safeSetColor(int r,int g,int b); + +/** + * Sets color using glColor4ub(), but handles potential overflow. + */ + void safeSetColorA(int r,int g,int b,int a); #endif // COMMON_H |