-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLiving.cpp
55 lines (48 loc) · 879 Bytes
/
Living.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
#include "living.h"
Living::Living() {
x = 0;
y = 0;
TempMap = new char* [7];
for (int i = 0; i < 7; ++i)
{
TempMap[i] = new char[7];
}
}
void Living::Init(char** map, int C, int L) {
time_t t;
srand((unsigned)time(&t));
do {
x = rand() % C;
y = rand() % L;
} while (map[y][x] != ' ');
}
int Living::getX() {
return x;
}
int Living::getY() {
return y;
}
void Living::setX(int _x) {
x = _x;
}
void Living::setY(int _y) {
y = _y;
}
void Living::CreateTempMap(char** map) {
int i, j;
for (i = 0; i < 7; i++)
for (j = 0; j < 7; j++)
{
if (y - 3 + i > 0 && y - 3 + i < 20 && x - 3 + j>0 && x - 3 + j < 60)
TempMap[i][j] = map[y - 3 + i][x - 3 + j];
else
TempMap[i][j] = '*';
}
/*for (i = 0; i < 7; i++){
for (j = 0; j < 7; j++)
mvprintw(i + 2, j + 63, "%c", TempMap[i][j]);
}*/
}
char** Living::getTempMap() {
return TempMap;
}