-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhow_to_play.h
More file actions
94 lines (84 loc) · 2.08 KB
/
how_to_play.h
File metadata and controls
94 lines (84 loc) · 2.08 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
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
#ifndef HOW_TO_PLAY_H_INCLUDED
#define HOW_TO_PLAY_H_INCLUDED
wchar_t *buffer = new wchar_t[80*25+1]{L' '};
int px = 11, py = 0;
wchar_t prev_char;
#include <fstream>
void howToPlay()
{
buffer[py * screen_width + px] = prev_char;
if (keyboard.isKeyHeld(VK_CONTROL) &&
keyboard.isKeyPressed('s'))
{
std::ofstream fout("text.txt");
for (int i = 0; i <= 80*25; ++i)
{
char ch = (buffer[i] == L' '? 222 : buffer[i]);
fout << ch;
if (i%80 == 0 && i > 2)fout<<std::endl;
}
fout.close();
}
if (keyboard.isKeyHeld(VK_CONTROL) &&
keyboard.isKeyPressed('l'))
{
char ch;int i = 0;
std::ifstream fin("text.txt");
while (fin >> ch)
{
if (ch == (char)222) ch = ' ';
buffer[i] = (wchar_t)ch;
++i;
if(i>=80*25)break;
}
fin.close();
}
if (keyboard.isKeyPressed(VK_DOWN))
++py;
if (keyboard.isKeyPressed(VK_UP))
--py;
if (keyboard.isKeyPressed(VK_RIGHT))
++px;
if (keyboard.isKeyPressed(VK_LEFT))
--px;
if (keyboard.isKeyPressed(VK_HOME))
px = 11;
if (keyboard.isKeyPressed(VK_RETURN))
py++,px=11;
if (mouse.isClicked())
px = mj > 10 ? mj : 11, py = mi;
if (px < 11) {px = 79;--py;}
if (py < 0) py = 0;
if (px > 79) {px = 11;++py;}
if (py > 24) py = 24;//*/
if (keyboard.isCharPressed())
{
buffer[py * screen_width + px] = keyboard.keyPressed();
if (px + 1 < 81)
++px;
else
{
px = 11;
++py;
}
}
//*/
if (keyboard.isKeyPressed(VK_BACK))
{
buffer[py * screen_width + px] = L' ';
if (px - 1 > 10)
--px;
else
{
px = 79;
--py;
}
}
prev_char = buffer[py * screen_width + px];
buffer[py * screen_width + px] = WHITE_SPACE;
for (int i = 0; i < 80*25; ++i)
{
screen[i] = buffer[i];
}
}
#endif // HOW_TO_PLAY_H_INCLUDED