Dungeon Crawl Enemies

I am making a Dungeon Crawl game from this site (http://www.cplusplus.com/forum/articles/12974/). I have all the game done I just don't know how to make the enemies. What I did for the player to move was I made a loop to find what the position of the player is and then depending on where he wants to move he changes position on the array "boards". However I don't know how to do the same for enemies as they are more than one and also i don't wont them all to move in the same direction. So the question is how do I implement enemies that move every second or so and all in random directions?
Thanks in advance.
Here is the code I have.

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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#include <iostream>
#include <conio.h>
#include <ctime>
#include <cstdlib>

using namespace std;

void boards();
int play();
int enemies();

char board[100];
char player = 'G';
char trap = 'T';
char finish = 'X';
char course = '=';
char enemy = 'E';
int counting=-1;
char key;
char PlayAgain;

int main()
{
    do
    {
        system("CLS");
        board[0]=player;
        srand(time(0));

        board[99]=finish;
        for(int i = 1;i<=98;i++)
        {
            int chance = rand()%10+1;
            if(chance<=2)
            {
                board[i] = 'T';
            }
            else if(chance>2)
            {
                board[i] = '=';
            }
        }
        boards();
        key = _getch();
        play();
        cout<<"Would you like to play again?(y/n)"<<endl;
        cin>>PlayAgain;
        while(PlayAgain!='y' && PlayAgain!='n')
        {
            cin>>PlayAgain;
        }
    }while(PlayAgain=='y');

    return 0;
}

int play()
{
    do
    {
        counting=-1;
        for(int x = 0;x<100;x++)
        {
            counting++;
            if(board[x]=='G')
            {
                break;
            }
        }
        if(counting==0)
        {
            while(key=='a' || key=='w')
            {
                key = _getch();
            }
        }
        else if(counting==9)
        {
            while(key=='d' || key=='w')
            {
                key = _getch();
            }
        }
        else if(counting==90)
        {
            while(key=='s' || key=='a')
            {
                key = _getch();
            }
        }
        else if(counting<=9)
        {
            while(key!='a' && key != 's' && key!='d' && key=='w')
            {
                key = _getch();
            }
        }
        else if(counting==0 || counting==10 || counting==20 || counting==30 || counting==40 || counting==50 || counting==60 || counting==70 || counting==80 || counting==90)
        {
            while(key!='w' && key != 's' && key!='d' && key=='a')
            {
                key = _getch();
            }
        }
        else if(counting>=90)
        {
            while(key!='a' && key != 'w' && key!='d' && key=='s')
            {
                key = _getch();
            }
        }
        else if(counting==9 || counting==19 || counting==29 || counting==39 || counting==49 || counting==59 || counting==69 || counting==79 || counting==89 || counting==99)
        {
            while(key!='a' && key != 's' && key!='w' && key=='d')
            {
                key = _getch();
            }
        }
        else
        {
            while(key!='w' && key!='a' && key!='s' && key!='d')
            {
                key = _getch();
            }
        }

        if(key=='w')
        {
            if(board[counting-10]==trap)
            {
                system("CLS");
                cout<<"You loose"<<endl;
                break;
            }
            else if(board[counting-10]==finish)
            {
                system("CLS");
                cout<<"You win"<<endl;
                break;
            }
            else if(board[counting-10]==course)
            {
                board[counting]=course;
                board[counting-10]=player;
                system("CLS");
                boards();
                key = _getch();
            }

        }
        else if(key=='a')
        {
            if(board[counting-1]==trap)
            {
                system("CLS");
                cout<<"You loose"<<endl;
                break;
            }
            else if(board[counting-1]==finish)
            {
                system("CLS");
                cout<<"You win"<<endl;
                break;
            }
            else if(board[counting-1]==course)
            {
                board[counting]=course;
                board[counting-1]=player;
                system("CLS");
                boards();
                key = _getch();
            }

        }
        else if(key=='s')
        {
            if(board[counting+10]==trap)
            {
                system("CLS");
                cout<<"You loose"<<endl;
                break;
            }
            else if(board[counting+10]==finish)
            {
                system("CLS");
                cout<<"You win"<<endl;
                break;
            }
            else if(board[counting+10]==course)
            {
                board[counting]=course;
                board[counting+10]=player;
                system("CLS");
                boards();
                key = _getch();
            }

        }
        else if(key=='d')
        {
            if(board[counting+1]==trap)
            {
                system("CLS");
                cout<<"You loose"<<endl;
                break;
            }
            else if(board[counting+1]==finish)
            {
                system("CLS");
                cout<<"You win"<<endl;
                break;
            }
            else if(board[counting+1]==course)
            {
                board[counting]=course;
                board[counting+1]=player;
                system("CLS");
                boards();
                key = _getch();
            }

        }
    }while(board[99]=='X');
}

int enemies()
{
    int enemies_movement = rand(time(0))%4;
    
}

void boards()
{
    cout<<board[0]<<" "<<board[1]<<" "<<board[2]<<" "<<board[3]<<" "<<board[4]<<" "<<board[5]<<" "<<board[6]<<" "<<board[7]<<" "<<board[8]<<" "<<board[9]<<endl;
    cout<<board[10]<<" "<<board[11]<<" "<<board[12]<<" "<<board[13]<<" "<<board[14]<<" "<<board[15]<<" "<<board[16]<<" "<<board[17]<<" "<<board[18]<<" "<<board[19]<<endl;
    cout<<board[20]<<" "<<board[21]<<" "<<board[22]<<" "<<board[23]<<" "<<board[24]<<" "<<board[25]<<" "<<board[26]<<" "<<board[27]<<" "<<board[28]<<" "<<board[29]<<endl;
    cout<<board[30]<<" "<<board[31]<<" "<<board[32]<<" "<<board[33]<<" "<<board[34]<<" "<<board[35]<<" "<<board[36]<<" "<<board[37]<<" "<<board[38]<<" "<<board[39]<<endl;
    cout<<board[40]<<" "<<board[41]<<" "<<board[42]<<" "<<board[43]<<" "<<board[44]<<" "<<board[45]<<" "<<board[46]<<" "<<board[47]<<" "<<board[48]<<" "<<board[49]<<endl;
    cout<<board[50]<<" "<<board[51]<<" "<<board[52]<<" "<<board[53]<<" "<<board[54]<<" "<<board[55]<<" "<<board[56]<<" "<<board[57]<<" "<<board[58]<<" "<<board[59]<<endl;
    cout<<board[60]<<" "<<board[61]<<" "<<board[62]<<" "<<board[63]<<" "<<board[64]<<" "<<board[65]<<" "<<board[66]<<" "<<board[67]<<" "<<board[68]<<" "<<board[69]<<endl;
    cout<<board[70]<<" "<<board[71]<<" "<<board[72]<<" "<<board[73]<<" "<<board[74]<<" "<<board[75]<<" "<<board[76]<<" "<<board[77]<<" "<<board[78]<<" "<<board[79]<<endl;
    cout<<board[80]<<" "<<board[81]<<" "<<board[82]<<" "<<board[83]<<" "<<board[84]<<" "<<board[85]<<" "<<board[86]<<" "<<board[87]<<" "<<board[88]<<" "<<board[89]<<endl;
    cout<<board[90]<<" "<<board[91]<<" "<<board[92]<<" "<<board[93]<<" "<<board[94]<<" "<<board[95]<<" "<<board[96]<<" "<<board[97]<<" "<<board[98]<<" "<<board[99]<<endl;
}
Topic archived. No new replies allowed.