forked from KMUlee/SnakeGameWithCPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.cpp
More file actions
44 lines (40 loc) · 1.1 KB
/
Map.cpp
File metadata and controls
44 lines (40 loc) · 1.1 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
//
// Map.cpp
// cpp_algo
//
// Created by 이승원 on 2022/05/01.
//
#include "Map.hpp"
//makeMap
int** makeMap(int row, int column, int stage) {
int** map = new int*[row];
for (int i = 0; i < row; i++) {
map[i] = new int[column];
for (int j = 0; j < column; j++) {
if (i == 0 || j == 0 || i == row - 1 || j == column - 1) {
map[i][j] = 1;
} else
map[i][j] = 0;
}
}
map[0][0] = map[0][column-1] = map[row-1][column-1] = map[row-1][0] = 2;
if (stage >= 2) {
for (int i = 0; i < row; i++) {
map[i][column / 2] = 1;
}
map[0][column/2] = 2;
map[row-1][column/2] = 2;
if (stage >= 3) {
for (int i = 0; i < column; i++) {
map[row/2][i] = 1;
}
map[row/2][column/2] = 2;
map[row/2][0] = map[row/2][column-1] = 2;
if (stage == 4) {
map[row/4][column/4] = 1;
map[row/2 + row/4][column/2 + column/4] = 1;
}
}
}
return map;
}