-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
51 lines (44 loc) · 1.48 KB
/
main.cpp
File metadata and controls
51 lines (44 loc) · 1.48 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
#include <SFML/Graphics.hpp>
#include "Cell.h"
#include "Grid.h"
#include <math.h>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 800), "Minesweeper", sf::Style::Titlebar | sf::Style::Close);
window.setFramerateLimit(60);
Grid g;
sf::Clock current;
float deltaTime;
float mouseDelay = 0;
while (window.isOpen() && !g.checkWin()) {
deltaTime = current.restart().asSeconds();
if(mouseDelay > 0){
mouseDelay -= deltaTime;
}else{
mouseDelay = 0;
}
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if(sf::Mouse::isButtonPressed(sf::Mouse::Left) && !mouseDelay){
sf::Vector2i mousPos = sf::Mouse::getPosition(window);
g.checkField(mousPos.x, mousPos.y);
//std::cout << "[Left] mPos_X: " << mousPos.x << " | " << "mPos_Y: " << mousPos.y << std::endl;
mouseDelay = 0.1;
}
if(sf::Mouse::isButtonPressed(sf::Mouse::Right) && !mouseDelay){
sf::Vector2i mousPos = sf::Mouse::getPosition(window);
g.switchFlag(mousPos.x, mousPos.y);
//std::cout << "[Left] mPos_X: " << mousPos.x << " | " << "mPos_Y: " << mousPos.y << std::endl;
mouseDelay = 0.1;
}
window.clear(sf::Color::White);
g.render(window);
window.display();
}
return 0;
}