Skip to content

Instantly share code, notes, and snippets.

@Aracturat
Last active August 29, 2015 14:21
Show Gist options
  • Save Aracturat/2ab9529fb2303fe4dc99 to your computer and use it in GitHub Desktop.
Save Aracturat/2ab9529fb2303fe4dc99 to your computer and use it in GitHub Desktop.
Narko Life
void MainWindow::updateView()
{
for (int x = 0; x < world -> getHeight(); x++)
{
for(int y = 0; y < world -> getWidth(); y++)
{
if (world -> getStatusOfCell(x, y)) {
pushButton[x*world->getHeight() + y]->setGeometry(x*BUTTON_HEIGHT, y*BUTTON_WIDTH, std::rand() % BUTTON_HEIGHT, std::rand() % BUTTON_WIDTH);
QString r = QString::number(std::rand() % 256, 16);
QString g = QString::number(std::rand() % 256, 16);
QString b = QString::number(std::rand() % 256, 16);
QString color = "\"#" + r + g + b + "\"";
setButtonColor(pushButtons[x*world->getHeight() + y], color);
}
else {
setButtonColor(pushButtons[x*world->getHeight() + y], QString::fromStdString(deathColor));
}
}
}
setLabelAliveNumber();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment