-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.cpp
115 lines (90 loc) · 1.65 KB
/
background.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
97
98
99
100
101
102
103
104
105
106
#include "background.h"
Wall::Wall()
{
left_wall = new block*[20];
right_wall = new block*[20];
hint_space = new block*[24];
build();
}
Wall::~Wall()
{
for(int i=0; i<20; ++i)
{
delete left_wall[i];
delete right_wall[i];
}
for(int i=0; i<24; ++i)
{
delete hint_space[i];
}
delete [] left_wall;
delete [] right_wall;
delete [] hint_space;
left_wall = NULL;
right_wall = NULL;
hint_space = NULL;
}
void Wall::build()
{
for(int i=0; i<20; ++i)
{
left_wall[i] = new block(ORI_X+INIT_X-5, ORI_Y+INIT_Y+i-16, "\e[45m \e[0m");
right_wall[i] = new block(ORI_X+INIT_X-5+11, ORI_Y+INIT_Y+i-16, "\e[45m \e[0m");
}
for(int i=0; i<7; ++i)
{
hint_space[i] = new block(ORI_X+INIT_X-5-7, ORI_Y+INIT_Y+i+13-16, "\e[45m \e[0m");
}
for(int i=0; i<7; ++i)
{
hint_space[i+7] = new block(ORI_X+INIT_X-5-2, ORI_Y+INIT_Y+i+13-16, "\e[45m \e[0m");
}
for(int i=0; i<5; ++i)
{
hint_space[i+14] = new block(ORI_X+INIT_X-5-2-i, ORI_Y+INIT_Y+19-16, "\e[45m \e[0m");
}
for(int i=0; i<5; ++i)
{
hint_space[i+19] = new block(ORI_X+INIT_X-5-3-i, ORI_Y+INIT_Y+13-16, "\e[45m \e[0m");
}
}
void Wall::display()
{
for(int i=0; i<20; ++i)
{
left_wall[i]->display();
right_wall[i]->display();
}
for(int i=0; i<24; ++i)
{
hint_space[i]->display();
}
}
Ground::Ground()
{
ground = new block*[10];
build();
}
void Ground::build()
{
for(int i=1; i<=10; ++i)
{
ground[i-1] = new block(INIT_X+ORI_X-5+i, INIT_Y+ORI_Y-16, "\e[45m \e[0m");
}
}
Ground::~Ground()
{
for(int i=0; i<10; ++i)
{
delete ground[i];
}
delete [] ground;
ground = NULL;
}
void Ground::display()
{
for(int i=0; i<10; ++i)
{
ground[i]->display();
}
}