-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
32 lines (27 loc) · 879 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
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include "game.hpp"
int main() {
sf::RenderWindow window(sf::VideoMode(600, 600), "TicTacToe", sf::Style::Default);
game ttt;
while (window.isOpen()) {
window.clear();
game::display_background(&window);
ttt.display_board(&window);
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
if (event.type == sf::Event::MouseButtonReleased && !ttt.isEnded()) {
ttt.update(sf::Mouse::getPosition(window).x,
sf::Mouse::getPosition(window).y);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) {
ttt.reset();
}
}
window.display();
}
return 0;
}