-
Notifications
You must be signed in to change notification settings - Fork 0
/
prim.cpp
61 lines (57 loc) · 1.41 KB
/
prim.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
#include "wall.h"
#include <ncurses.h>
void Prims(char** map, int map_hight, int map_width, int y_start, int x_start, int y, int x){
//Implimentation of prims algorithm.
wall* a_wall = new wall(y_start,x_start);
wall_array wall_list;
bool stop = false;
wall_list.add_wall(a_wall);
do
{
if(wall_list.get_size()==0)
{
stop=true;
map[a_wall->y][a_wall->x]='E';
mvprintw(a_wall->y,a_wall->x,"#");
refresh();
delete a_wall;
}
else
{
delete a_wall;
a_wall = new wall(wall_list.rand_wall());
wall_list.remove_wall(a_wall);
map[a_wall->y][a_wall->x]='V';
wall_list.add_neighbors(a_wall,map,map_hight,map_width);
attron(COLOR_PAIR(3));
mvprintw(a_wall->y,a_wall->x,"%c",map[a_wall->y][a_wall->x]);
attroff(COLOR_PAIR(3));
refresh();
}
}
while(!stop);
for(int k = 0; k < map_hight ; k++)
{
for(int i = 0; i < map_width ; i++)
{
if(map[k][i]=='#')
{
attron(COLOR_PAIR(1));
mvprintw(k,i,"%c",map[k][i]);
attroff(COLOR_PAIR(1));
}
else if(map[k][i]=='V'||map[k][i]=='S')
{
attron(COLOR_PAIR(3));
mvprintw(k,i,"%c",map[k][i]);
attroff(COLOR_PAIR(3));
}
else
{
attron(COLOR_PAIR(2));
mvprintw(k,i,"%c",map[k][i]);
attroff(COLOR_PAIR(2));
}
}
}
}