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
|
#include "MainWindow.hpp"
MainWindow::MainWindow(int width, int height, std::string title):
RenderWindow(sf::VideoMode(width,height), title,sf::Style::Titlebar | sf::Style::Close),
m_skin(),
m_windowMargin(10),
m_sizeCell(120),
m_spaceBetweenCell(10)
{
//Define skin:
m_skin.push_back(sf::Color(250,248,239)); //Background MainWindow
m_skin.push_back(sf::Color(205,192,180)); //Background cells
}
MainWindow::~MainWindow(){
}
void MainWindow::clearBG(){
RenderWindow::clear(m_skin.at(0));
}
void MainWindow::drawCells(){
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
sf::RectangleShape cell(sf::Vector2f(m_sizeCell, m_sizeCell));
cell.setFillColor(m_skin.at(1));
int centerOffset=(800-(3*m_spaceBetweenCell+4*m_sizeCell))/2;
int distanceBetweenTopAndGrid=200;
cell.setPosition(centerOffset+j*(m_sizeCell+m_spaceBetweenCell),distanceBetweenTopAndGrid+i*(m_sizeCell+m_spaceBetweenCell));
RenderWindow::draw(cell);
}
}
}
|