-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpainter.cpp
More file actions
58 lines (54 loc) · 1.16 KB
/
Copy pathpainter.cpp
File metadata and controls
58 lines (54 loc) · 1.16 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "painter.h"
void BoardPainter::paint()
{
if (window)
{
Sprite sprite(mtexture);
for (int i = 0; i < mWidth; i++)
{
for (int j = 0; j < mHeight; j++)
{
sprite.setPosition(i * CELL_SIZE, j * CELL_SIZE);
window->draw(sprite);
}
}
}
}
void SnakePainter::paint()
{
if (window)
{
Sprite sprite(mtexture);
for (int i = 0; i <mSize; i++)
{
sprite.setPosition(mCord[i].X * CELL_SIZE,mCord[i].Y * CELL_SIZE);
window->draw(sprite);
}
}
}
void FruitPainter::paint()
{
if (window)
{
Sprite sprite(mtexture);
sprite.setPosition(mCord.X * CELL_SIZE, mCord.Y * CELL_SIZE);
window->draw(sprite);
}
}
void GameOverPainter::paint()
{
Sprite sprite;
Font font;
if (font.loadFromFile("Windsong.ttf"))
{
Text text;
text.setFont(font);
text.setString("Game over!");
text.setFillColor(Color::Red);
text.setCharacterSize(80);
FloatRect textRect = text.getLocalBounds();
text.setOrigin(textRect.left + textRect.width / 2.0f,textRect.top + textRect.height / 2.0f);
text.setPosition(Vector2f(ROWS*CELL_SIZE / 2.0f, COLUMBS * CELL_SIZE / 2.0f));
window->draw(text);
}
}