-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtile.h
70 lines (60 loc) · 1.73 KB
/
tile.h
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
//
// Created by aaron on 4/18/2024.
//
#include <iostream>
#include <cctype>
#include "board.h"
#include "textureManager.h"
#pragma once
using namespace std;
struct tile {
bool isRevealed;
bool isFlagged;
bool isMine;
vector<tile*> neighbors;
sf::Sprite back;
sf::Sprite front;
sf::Sprite icon;
sf::Sprite flag;
map<string,sf::Texture> textures;
tile(map<string,sf::Texture>& textures, float xpos, float ypos) {
back.setPosition(xpos, ypos);
front.setPosition(xpos, ypos);
icon.setPosition(xpos,ypos);
flag.setPosition(xpos,ypos);
back.setTexture(textures["tile_revealed"]);
front.setTexture(textures["tile_hidden"]);
flag.setTexture(textures["flag"]);
//flag.setColor(sf::Color(255,255,255,0));
isRevealed = false;
isFlagged = false;
isMine = false;
this->textures = textures;
}
// bool tileClicked(float positionx, float positiony) {
// if(back.getGlobalBounds().contains(positionx,positiony)) {
// cout << isRevealed << "The tile has been revealed" << endl;
// this->isRevealed = true;
// return true;
// }
// return false;
// }
void draw(sf::RenderWindow& window) {
if (!isRevealed) {
window.draw(front);
}
else if (isRevealed){
window.draw(back);
}
if (isFlagged) {
window.draw(flag);
}
if (isMine && isRevealed) {
icon.setTexture(textures["mine"]);
window.draw(icon);
}
}
};
#ifndef MINESWEEPER_TILE_H
#define MINESWEEPER_TILE_H
#endif //MINESWEEPER_TILE_H