Arch Game Engine  0.2
engine.h
1 #ifndef ENGINE_H
2 #define ENGINE_H
3 
4 #include <SDL2/SDL.h>
5 #include <SDL2/SDL_ttf.h>
6 using namespace std;
7 #include <iostream>
8 #include <cassert>
9 #include <string>
10 #include <unistd.h>
11 #include <sys/time.h>
12 #include <vector>
13 #include <ctime>
14 #include <time.h>
15 #include <GL/gl.h>
16 #include <GL/glu.h>
17 
18 #include "image.h"
19 #include "object.h"
20 #include "background.h"
21 #include "tile.h"
22 #include "entity.h"
23 #include "collision.h"
24 #include "tileset.h"
25 #include "input.h"
26 #include "physics-tmp.h"
27 #include "stage.h"
28 #include "level.h"
29 #include "gamestate.h"
30 
31 /*
32 #include "splash.h"
33 */
34 
36 class Engine {
37 private:
38  SDL_Renderer* engren;
39  SDL_Window *engwin;
40  int WIDTH, HEIGHT;
41  int simulationTime, realTime;
42  //bool fps; //!< Boolean for loop.
43  bool bkg;
44  Background background;
45  Uint8 red, green, blue;
46  bool debug;
47  bool running;
48  time_t lastTime, curTime;
49  long capLast, capCur;
50  int frameCount;
51  //int framesPerSecond, cappedFrame, capTime, capMark, renderMiliGap;
52  bool glMode;
53  int glView[9];
54  int curFPS, setFPS, lastFrame;
55  double gravity;
56  TTF_Font *font;
57  GameState gs;
58  int sr,sg,sb;
59 public:
60  Engine();
62  ~Engine();
63  void setGravity(double g) {gravity=g;}
64  void setFrameRate(int f) {setFPS=f;}
65  double getGravity() const {return gravity;}
67  SDL_Renderer* init(string s, const int& w, const int& h, int flag);
69  SDL_Renderer* init(string s, const int& w, const int& h, int flag, int it);
71  SDL_Renderer* init(string s, const int& w, const int& h, int flag, int x, int y);
73  SDL_Renderer* init(string s, const int& w, const int& h, int flag, int x, int y, int it);
75  void setName(string s);
77  void setPos(int x, int y);
79  void setSize(int w, int y);
81  SDL_Renderer* getRenderer();
83  SDL_Window* getWindow() const { return engwin; }
85  void setColor(Uint8 r, Uint8 g, Uint8 b);
87  void loopStart();
89  void render();
91  //bool FPS() const { return fps; }
93  void update();
95  void setBackground(Background b) { background = b; }
97  void setBackground(string filename);
99  Background getBackground() const { return background; }
101  void drawBackground();
103  void draw(Object obj);
105  void draw(vector<Object> objs);
106  void draw(vector<vector<Object>> objs);
108  void draw(Object obj, int key);
110  void draw(Level lvl);
112  void draw(const char *text, int x, int y, int r, int g, int b);
114  void splash();
116  void bypassSplash(int key);
118  bool hasSplashed();
120  void debugMode(bool d);
121  void loadFont(char *font_path);
122  void hideMouse();
123  void showMouse();
124  bool getRunning() const { return running; }
125  void setRunning(bool r) { running = r; }
126  void setGLView(int a, int b, int c, int d, int e, int f, int g, int h, int i);
127  void setGLMode(bool m) {glMode=m; glViewport(0, 0, WIDTH, HEIGHT); }
128  int getFPS() const {return curFPS;}
129  void loop();
130  int getTicks();
131  void delay(int time);
132  void enableTransparency() {SDL_SetRenderDrawBlendMode(engren, SDL_BLENDMODE_BLEND);}
133  struct color { Uint8 r, g, b; };
134  void setGamestate(int s) {if(gs.getGameState()!=0) gs.setGameState(s);}
135  int getGameState() {return gs.getGameState();}
136  void setSplashColor(int r, int g, int b) {sr=r;sg=g;sb=b;}
137 };
138 
139 #endif //ENGINE_H
This class stores information for an Object in the game.
Definition: object.h:12
void setBackground(Background b)
Set background.
Definition: engine.h:95
Class for declaring an engine, which does basic SDL commands like creating the window and renderer...
Definition: engine.h:36
Object that is a background image that covers the screen.
Definition: background.h:7
SDL_Window * getWindow() const
Returns screen window.
Definition: engine.h:83
This class stores a Stage and Objects and can move them and display them.
Definition: level.h:10
Background getBackground() const
Get background.
Definition: engine.h:99