Add original 2048 skin !
This commit is contained in:
parent
7f0edabb5d
commit
fb7fb90b85
2 changed files with 54 additions and 5 deletions
|
@ -13,10 +13,32 @@ MainWindow::MainWindow(int width, int height, std::string title):
|
||||||
m_spaceBetweenCell(10)
|
m_spaceBetweenCell(10)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Define skin:
|
//Define original skin:
|
||||||
m_skin.push_back(sf::Color(250,248,239)); //Background MainWindow
|
m_skin.push_back(sf::Color(250,248,239)); //Background MainWindow
|
||||||
m_skin.push_back(sf::Color(205,192,180)); //Background cells
|
m_skin.push_back(sf::Color(205,192,180)); //Background cells
|
||||||
|
m_skin.push_back(sf::Color(187,173,160)); //Background grid color
|
||||||
|
m_skin.push_back(sf::Color(119,110,101)); //2 and 4 font color
|
||||||
|
m_skin.push_back(sf::Color(249,246,242)); //other number font Color
|
||||||
|
|
||||||
|
//Skin 2 et le 4
|
||||||
|
m_skin.push_back(sf::Color(238,228,218)); //2
|
||||||
|
m_skin.push_back(sf::Color(237,224,200)); //4
|
||||||
|
|
||||||
|
//Skin 8 à 64
|
||||||
|
m_skin.push_back(sf::Color(242,177,121)); //8
|
||||||
|
m_skin.push_back(sf::Color(245,149,99)); //16
|
||||||
|
m_skin.push_back(sf::Color(246,124,95)); //32
|
||||||
|
m_skin.push_back(sf::Color(246,94,59)); //64
|
||||||
|
|
||||||
|
//Skin 128 à 2048
|
||||||
|
m_skin.push_back(sf::Color(237,207,114)); //128
|
||||||
|
m_skin.push_back(sf::Color(237,204,97)); //256
|
||||||
|
m_skin.push_back(sf::Color(237,200,80)); //512
|
||||||
|
m_skin.push_back(sf::Color(237,197,63)); //1024
|
||||||
|
m_skin.push_back(sf::Color(238,194,46)); //2048
|
||||||
|
|
||||||
|
//Skin for other number
|
||||||
|
m_skin.push_back(sf::Color(60,58,50)); //More than 2048
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,16 +53,42 @@ void MainWindow::clearBG(){
|
||||||
|
|
||||||
void MainWindow::drawCells(){
|
void MainWindow::drawCells(){
|
||||||
|
|
||||||
|
int centerOffset=(800-(3*m_spaceBetweenCell+4*m_sizeCell))/2;
|
||||||
|
int distanceBetweenTopAndGrid=200;
|
||||||
|
int bgsize=3*m_spaceBetweenCell + 4*m_sizeCell + 2*m_spaceBetweenCell;
|
||||||
|
sf::RectangleShape gridBG(sf::Vector2f(bgsize, bgsize));
|
||||||
|
gridBG.setFillColor(m_skin.at(2));
|
||||||
|
gridBG.setPosition(centerOffset-m_spaceBetweenCell,distanceBetweenTopAndGrid - m_spaceBetweenCell);
|
||||||
|
RenderWindow::draw(gridBG);
|
||||||
for(int i=0;i<4;i++){
|
for(int i=0;i<4;i++){
|
||||||
|
|
||||||
for(int j=0;j<4;j++){
|
for(int j=0;j<4;j++){
|
||||||
sf::RectangleShape cell(sf::Vector2f(m_sizeCell, m_sizeCell));
|
sf::RectangleShape cell(sf::Vector2f(m_sizeCell, m_sizeCell));
|
||||||
cell.setFillColor(m_skin.at(1));
|
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));
|
cell.setPosition(centerOffset+j*(m_sizeCell+m_spaceBetweenCell),distanceBetweenTopAndGrid+i*(m_sizeCell+m_spaceBetweenCell));
|
||||||
RenderWindow::draw(cell);
|
RenderWindow::draw(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sf::Color MainWindow::getCellColor(int value){
|
||||||
|
|
||||||
|
//Id of the first cell color skin
|
||||||
|
int idStart=5;
|
||||||
|
|
||||||
|
if(value%2==0){
|
||||||
|
int result(value);
|
||||||
|
int id(idStart);
|
||||||
|
while(result!=2){
|
||||||
|
result/=2;
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
return m_skin.at(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return m_skin.at(idStart+11);
|
||||||
|
}
|
||||||
|
|
|
@ -20,5 +20,6 @@ class MainWindow : public sf::RenderWindow{
|
||||||
|
|
||||||
void clearBG();
|
void clearBG();
|
||||||
void drawCells();
|
void drawCells();
|
||||||
|
sf::Color getCellColor(int value);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue