-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.hpp
95 lines (67 loc) · 1.68 KB
/
window.hpp
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef WINDOW_H
#define WINDOW_H
#include <map>
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include "audio.hpp"
#include "gamepad.hpp"
class Window
{
private:
// SDL default window
SDL_Window* window = nullptr;
// SDL renderer
SDL_Renderer* renderer;
// SDL Gamepad Manager
GamepadManager gamepads;
// Window state flag
bool is_open = false;
// Delta timings
uint64_t now, last;
double delta_time = 0;
// Window sizes
uint32_t size_x, size_y;
// Keys
std::map<SDL_Keycode, bool> pressed, released, state;
// Audio controller
Audio* audio;
public:
// Constructor
Window();
// Gets main renderer
SDL_Renderer* getRenderer();
// Sets the title of the window
void setTitle(std::string what);
// Get gamepad manager
GamepadManager* getGamepadManager();
// Clears the contents of the window
void clear();
// Updates the contents of the window
void update();
// Get window size
std::pair<uint32_t, uint32_t> getSize();
// Get audio
Audio* getAudio();
// Gets window state
bool isOpen();
// Resizes window
void resize(uint32_t newX, uint32_t newY);
// Gets key status
bool getKey(SDL_Keycode key);
// Gets key pressed status
bool getKeyPressed(SDL_Keycode key);
// Gets key released status
bool getKeyReleased(SDL_Keycode key);
// Updates input from event
void updateInput(SDL_Event event);
// Resets inputs
void updateInput();
// Update delta time
void updateDelta();
// Get delta time
double getDelta();
// Closes the window
void close();
};
#endif