-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·56 lines (47 loc) · 1.51 KB
/
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
#include "boxField.hpp"
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Mineraker",
sf::Style::Titlebar | sf::Style::Close);
BoxField boxField(200, window.getSize().x, window.getSize().y);
window.setVerticalSyncEnabled(true);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
case sf::Event::MouseButtonPressed:
if (event.mouseButton.button == sf::Mouse::Left)
{
boxField.press(sf::Vector2u(event.mouseButton.x,
event.mouseButton.y));
boxField.checkIfWon();
}
else if (event.mouseButton.button == sf::Mouse::Right)
{
if (boxField.isOver()) {
boxField.reset();
} else {
boxField.mark(sf::Vector2u(event.mouseButton.x,
event.mouseButton.y));
boxField.checkIfWon();
}
}
break;
default:
break;
}
}
window.clear();
boxField.draw(window);
window.display();
}
return 0;
}