Quickly draw basic grid (no reliable code)
This commit is contained in:
parent
ce3f721e16
commit
7f0edabb5d
3 changed files with 35 additions and 9 deletions
|
@ -29,7 +29,8 @@ void SFMLController::run(){
|
||||||
if (event.type == sf::Event::Closed)
|
if (event.type == sf::Event::Closed)
|
||||||
m_MainWindow.close();
|
m_MainWindow.close();
|
||||||
}
|
}
|
||||||
m_MainWindow.clearMW();
|
m_MainWindow.clearBG();
|
||||||
|
m_MainWindow.drawCells();
|
||||||
m_MainWindow.display();
|
m_MainWindow.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,16 @@
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(int width, int height, std::string title):
|
MainWindow::MainWindow(int width, int height, std::string title):
|
||||||
RenderWindow(sf::VideoMode(width,height), title),
|
RenderWindow(sf::VideoMode(width,height), title,sf::Style::Titlebar | sf::Style::Close),
|
||||||
skin()
|
m_skin(),
|
||||||
|
m_windowMargin(10),
|
||||||
|
m_sizeCell(120),
|
||||||
|
m_spaceBetweenCell(10)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Define skin:
|
//Define skin:
|
||||||
skin.push_back(sf::Color(250,248,239));
|
m_skin.push_back(sf::Color(250,248,239)); //Background MainWindow
|
||||||
|
m_skin.push_back(sf::Color(205,192,180)); //Background cells
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +24,23 @@ MainWindow::MainWindow(int width, int height, std::string title):
|
||||||
MainWindow::~MainWindow(){
|
MainWindow::~MainWindow(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::clearMW(){
|
void MainWindow::clearBG(){
|
||||||
RenderWindow::clear(skin.at(0));
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,15 @@
|
||||||
class MainWindow : public sf::RenderWindow{
|
class MainWindow : public sf::RenderWindow{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<sf::Color> skin;
|
std::vector<sf::Color> m_skin;
|
||||||
|
int m_windowMargin;
|
||||||
|
int m_sizeCell;
|
||||||
|
int m_spaceBetweenCell;
|
||||||
public:
|
public:
|
||||||
MainWindow(int width, int height, std::string title);
|
MainWindow(int width, int height, std::string title);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
void clearMW();
|
void clearBG();
|
||||||
|
void drawCells();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue