gamedev
common.h
1 #ifndef COMMON_H
2 #define COMMON_H
3 
4 /*
5  * Include basic C/C++ facilities
6 */
7 
8 #include <iostream>
9 #include <cstdlib>
10 #include <vector>
11 #include <math.h>
12 #include <thread>
13 
14 /*
15  * Include GLEW and the SDL 2 headers
16 */
17 
18 #define GLEW_STATIC
19 #include <GL/glew.h>
20 
21 #include <SDL2/SDL.h>
22 #include <SDL2/SDL_opengl.h>
23 #include <SDL2/SDL_image.h>
24 #include <SDL2/SDL_mixer.h>
25 #include <string>
26 #include <fstream>
27 
28 
29 #ifdef __WIN32__
30 typedef unsigned int uint;
31 #undef near
32 #endif
33 
34 #include <Texture.h>
35 
36 /*
37  * This flag lets the compiler know that we are using shaders
38 */
39 
40 #define SHADERSs
41 
42 /*
43  * Create a basic 2-point structure for coordinate saving
44 */
45 
46 typedef struct {
47  float x;
48  float y;
49 } vec2;
50 
51 typedef struct {
52  vec2 start;
53  vec2 end;
54 } Ray;
55 
56 /*
57  * Define the game's name (displayed in the window title),
58  * the desired window dimensions,
59  * and whether or not we want the window to be fullscreen.
60 */
61 
62 #define GAME_NAME "Independent Study v.0.4 alpha"
63 
64 #define SCREEN_WIDTH 1280
65 #define SCREEN_HEIGHT 720
66 
67 //#define FULLSCREEN
68 
69 /*
70  * Define the length of a single HLINE.
71  *
72  * The game has a great amount of elements that need to be drawn or detected, and having each
73  * of them use specific hard-coded numbers would be painful to debug. As a solution, this
74  * definition was made. Every item being drawn to the screen and most object detection/physic
75  * handling is done based off of this number. Increasing it will give the game a zoomed-in
76  * feel, while decreasing it will do the opposite.
77  *
78 */
79 
80 #define HLINE 3 // 3 as in 3 pixels
81 
82 /*
83  * Define 'our' random number generation library. Eventually these macros will be replaced
84  * with actual functions.
85  *
86 */
87 
88 #define initRand(s) srand(s)
89 #define getRand() rand()
90 
91 /*
92  * At the bottom of this header is the prototype for DEBUG_prints, which writes a formatted
93  * string to the console containing the callee's file and line number. This macro simplifies
94  * it to a simple printf call.
95  *
96  * DEBUG must be defined for this macro to function.
97  *
98 */
99 
100 #define DEBUG_printf( message, ...) DEBUG_prints(__FILE__, __LINE__, message, __VA_ARGS__ )
101 
102 
103 #define PI 3.1415926535
104 
105 
106 /*
107  * References the variable in main.cpp, used for smoother drawing.
108 */
109 
110 extern unsigned int deltaTime;
111 
112 /*
113  * References the variable in main.cpp, used for drawing with the player
114 */
115 extern vec2 offset;
116 
117 extern float handAngle;
118 
119 extern unsigned int loops;
120 
121 /*
122  * Prints a formatted debug message to the console, along with the callee's file and line
123  * number.
124  *
125 */
126 
127 void DEBUG_prints(const char* file, int line, const char *s,...);
128 
129 void safeSetColor(int r,int g,int b);
130 void safeSetColorA(int r,int g,int b,int a);
131 
132 #endif // COMMON_H
Definition: common.h:46
float y
Definition: world.h:88
Definition: common.h:51