-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
57 lines (48 loc) · 924 Bytes
/
main.cpp
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
#include <iostream>
#include <cmath>
#include "RSDL/src/rsdl.hpp"
using namespace std;
Point mousePosition;
class Ball {
public:
void update(Window* window) {
x = mousePosition.x;
y = mousePosition.y;
}
void draw(Window* window) {
window->fill_circle(Point(x,y), 20);
}
private:
float x, y;
};
Ball ball;
void update(Window* window) {
while(window->has_pending_event()) {
Event e = window->poll_for_event();
switch(e.get_type()) {
case Event::EventType::QUIT:
exit(0);
break;
case Event::EventType::MMOTION:
mousePosition = e.get_mouse_position();
break;
}
}
ball.update(window);
}
void draw(Window* window) {
window->clear();
window->draw_rect(Rectangle(100, 100, 200, 200));
ball.draw(window);
window->update_screen();
}
int main()
{
Window *window = new Window(1000, 1000, "RSDL Demo");
while(true) {
update(window);
draw(window);
delay(15);
}
return 0;
}