-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper.hpp
More file actions
74 lines (55 loc) · 1.5 KB
/
wrapper.hpp
File metadata and controls
74 lines (55 loc) · 1.5 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
73
74
/* wrapper
* by python-b5
*
* A small wrapper around SDL2, providing basic sprite and text drawing
* capabilities.
*/
// standard libraries
#include <string>
#include <vector>
// external libraries
#include <SDL2/SDL.h>
#ifndef WRAPPER
#define WRAPPER
namespace wrapper {
// structs/classes
struct Color {
uint8_t r, g, b;
uint8_t a;
Color(uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_ = 255);
};
class Sprite {
SDL_Texture *texture;
int width;
int height;
public:
Sprite();
Sprite(std::string file);
Sprite(SDL_Surface *surface);
void draw(int x, int y);
int get_width() const;
int get_height() const;
};
class BBox {
public:
int x1, y1;
int x2, y2;
BBox();
BBox(int x1_, int y1_, int x2_, int y2_);
bool collision(const BBox &other);
bool collision(int point_x, int point_y);
};
// functions
bool initialize(
int width, int height, int fps,
std::string title, std::string icon
);
void quit();
bool update();
void clear(const Color &color = Color(0, 0, 0, 0));
bool mouse_down();
bool mouse_clicked();
int get_mouse_x();
int get_mouse_y();
}
#endif