-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.h
More file actions
72 lines (56 loc) · 1.57 KB
/
Engine.h
File metadata and controls
72 lines (56 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Engine is an abstract class whose functionality lies mainly in App.
// App is the clean template and interface for the programmer while this
// Does "behind the scenes" work
#pragma once
#include <SDL.h>
#include "Screen.h"
#include "Scene.h"
#include "Rasterizer.h"
#include "SoftwareDevice.h"
const UINT INPUT_SIZE = 122;
class Engine
{
private:
// The index of each element in the array represents the ascii value of the key pressed
// This way I can garuntee input is always ordered and it doesn't require a search
bool mCurrentKeyState[INPUT_SIZE];
bool mPreviousKeyState[INPUT_SIZE];
SDL_Window* mWindow;
SDL_Renderer* mRenderer;
SDL_Texture* mTexture;
bool mRunning;
private:
// Posts the key
void KeyIsDown(char key) { mCurrentKeyState[key] = true; }
void KeyIsUp(char key) { mCurrentKeyState[key] = false; }
protected:
SoftwareDevice sDevice;
float fTime;
UINT prevTime;
UINT currTime;
protected:
// Gets the key
bool IsCurrentKeyDown(char key) { return mCurrentKeyState[key]; }
bool IsPreviousKeyDown(char key) { return mPreviousKeyState[key]; }
public:
bool IsRunning() const { return mRunning; }
void Quit() { mRunning = false; }
float GetFrameTime() { return fTime; }
SDL_Window* GetSDLWindow() { return mWindow; }
public:
Engine();
~Engine();
void Tick();
void EngineInitialize();
virtual void Initialize();
void EngineLoad();
virtual void Load();
void EngineUpdate();
virtual void Update();
void Input(SDL_Event e);
inline void PushKeyState();
void EngineUnLoad();
virtual void UnLoad();
void EngineDraw();
virtual void Draw();
};