1212std::atomic_bool mouseRightPressed = false ;
1313std::atomic_bool mouseLeftPressed = false ;
1414
15- // Update the next grid
15+ // Update the next grid state
1616static void updateGrid (const sf::RenderWindow& window)
1717{
18- // Get the next grid to write to
18+ // Get the writable next grid
1919 auto [nextGrid, writeLock] = grid.writeBuffer ();
2020
2121 // Handle right mouse button click
@@ -31,7 +31,7 @@ static void updateGrid(const sf::RenderWindow& window)
3131 nextGrid.updateGrid (currGrid);
3232 }
3333
34- // Add some noise to the grid
34+ // Add random noise to the grid
3535 nextGrid.addNoise ();
3636
3737 // Handle mouse movement while the left button is pressed
@@ -40,15 +40,15 @@ static void updateGrid(const sf::RenderWindow& window)
4040 const int x = mousePos.x / CELL_SIZE;
4141 const int y = mousePos.y / CELL_SIZE;
4242 if (x >= 0 && x < GRID_SIZE && y >= 0 && y < GRID_SIZE) {
43- nextGrid.toggleBlock ({ x, y }); // Turn on a 3x3 block
43+ nextGrid.toggleBlock ({ x, y }); // Toggle a 3x3 block
4444 }
4545 }
4646
4747 // Swap the buffers
4848 grid.swap (std::move (writeLock));
4949}
5050
51- // Color map for cells based on number of live neighbors
51+ // Color map for cells based on the number of live neighbors
5252static const std::array<sf::Color, 9 > colorMap {
5353 sf::Color::Red, // 0 live neighbors
5454 sf::Color::Green, // 1 live neighbor
@@ -64,7 +64,7 @@ static const std::array<sf::Color, 9> colorMap {
6464// Function to update the vertex array
6565int updateVertices (sf::RenderWindow& window, sf::VertexArray& vertices)
6666{
67- int numAlive = 0 ; // Count the number of alive cells
67+ int numAlive = 0 ; // Count of alive cells
6868 auto [currGrid, lock] = grid.readBuffer ();
6969 for (int i = 0 ; i < GRID_SIZE; ++i) {
7070 for (int j = 0 ; j < GRID_SIZE; ++j) {
@@ -134,7 +134,7 @@ int main()
134134 }
135135 }
136136
137- // Text to display the number of alive cells
137+ // Load font for displaying text
138138 sf::Font font;
139139 const std::vector<std::string> fontPaths {
140140#ifdef _WIN32
0 commit comments