-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrid.cpp
More file actions
39 lines (32 loc) · 1012 Bytes
/
Copy pathGrid.cpp
File metadata and controls
39 lines (32 loc) · 1012 Bytes
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
#include <SFML/Graphics.hpp>
#include "Grid.h"
using namespace sfSnake;
Grid::Grid()
{
for (int i = 0; i < Game::Height / Grid::Space; ++i)
{
Grid_x.emplace_back(sf::RectangleShape(sf::Vector2f(Game::Width, Grid::Length)));
Grid_x[i].setPosition(0, Grid::Space * (i + 1));
Grid_x[i].setFillColor(Game::Grid_Color);
}
for (int i = 0; i < Game::Width / Grid::Space; ++i)
{
Grid_y.emplace_back(sf::RectangleShape(sf::Vector2f(Grid::Length, Game::Height)));
Grid_y[i].setPosition(Grid::Space * (i + 1), 0);
Grid_y[i].setFillColor(Game::Grid_Color);
}
}
void Grid::setFillColor()
{
for (auto &grid : Grid_x)
grid.setFillColor(Game::Grid_Color);
for (auto &grid : Grid_y)
grid.setFillColor(Game::Grid_Color);
}
void Grid::render(sf::RenderWindow &window)
{
for (auto &grid : Grid_x)
window.draw(grid);
for (auto &grid : Grid_y)
window.draw(grid);
}