-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIO.cpp
96 lines (76 loc) · 1.43 KB
/
IO.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "IO.h"
IO::IO(void)
{
InitGraph ();
}
IO::~IO(void)
{
}
void IO::ClearScreen()
{
window.clear();
}
void IO::DrawRectangle (int pX1, int pY1, int pX2, int pY2, sf::Color color, bool isGhost)
{
rectangle.setPosition(pX1,pY1);
rectangle.setSize(sf::Vector2f(pX2,pY2));
rectangle.setFillColor(color);
if(isGhost)
{
rectangle.setOutlineColor(sf::Color::White);
rectangle.setFillColor(sf::Color::Transparent);
rectangle.setOutlineThickness(1);
window.draw(rectangle);
return;
}
else
{
rectangle.setOutlineThickness(0);
window.draw(rectangle);
}
}
int IO::GetScreenHeight()
{
return HEIGHT;
}
void IO::UpdateScreen()
{
window.display();
}
int IO::Pollkey()
{
sf::Event event;
while (window.pollEvent(event))
{
switch(event.type) {
case sf::Event::KeyPressed:
return event.key.code;
case sf::Event::Closed:
exit(3);
}
}
return -1;
}
int IO::InitGraph()
{
window.create(sf::VideoMode(WIDTH, HEIGHT), "NULLtress");
return 0;
}
void IO::DrawScore(int pScore)
{
sf::Font font;
font.loadFromFile("font.ttf");
sf::Text text("Number of Lines Cleared:", font);
sf::Text tScore;
text.setPosition(20,50);
text.setColor(sf::Color::White);
text.setCharacterSize(10);
std::string s = std::to_string(pScore);
tScore.setString(s);
tScore.setPosition(50,70);
tScore.setFont(font);
tScore.setColor(sf::Color::Cyan);
tScore.setCharacterSize(12);
window.draw(text);
window.draw(tScore);
}