-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.cpp
More file actions
44 lines (35 loc) · 779 Bytes
/
Copy pathMap.cpp
File metadata and controls
44 lines (35 loc) · 779 Bytes
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
// ---------------------------------------------------------------------------
#pragma hdrstop
#include "Map.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
Map::Map(int cols, int rows) {
this->cols = cols;
this->rows = rows;
this->map = new int[rows * cols];
for (int i = 0; i < rows * cols; i++)
this->map[i] = 0;
}
Map::~Map() {
delete[]map;
}
void Map::RandomMap(float ObstaclePercent) {
for (int i = 0; i < rows * cols; i++) {
if (random(100) < ObstaclePercent)
this->map[i] = -1;
}
}
int* Map::GetMap() {
return this->map;
}
int Map::GetRowsCount()
{
return this->rows;
}
int Map::GetColsCount(){
return this->cols;
}
void Map::SetObstacle(int x,int y)
{
map[ y*cols + x] = -1;
}