-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_tab.cpp
50 lines (47 loc) · 1.29 KB
/
load_tab.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
inline void carregar_tabuleiro(char *arquivo, board &tabuleiro)
{
FILE *tabuleiro_arq;
char temp[30], x, y;
//Abrir o arquivo que contem as informacoes do tabuleiro
tabuleiro_arq = fopen(arquivo, "r");
y = 0;
while(!feof(tabuleiro_arq))
{
y++;
fgets(temp, 29, tabuleiro_arq);
for(x = 0; x <= 27; x++)
{
if(((VAZIO <= temp[x]) && (temp[x] <= T_ESQUERDA)) || (temp[x] == RESERVADO))
{
tabuleiro[x + 1][y] = temp[x];
}
else
{
tabuleiro[x + 1][y] = temp[x];
switch(temp[x])
{
case CABECA_CIMA:
posicao_inicial_x = x + 1;
posicao_inicial_y = y;
direcao_inicial = CIMA;
break;
case CABECA_BAIXO:
posicao_inicial_x = x + 1;
posicao_inicial_y = y;
direcao_inicial = BAIXO;
break;
case CABECA_ESQUERDA:
posicao_inicial_x = x + 1;
posicao_inicial_y = y;
direcao_inicial = ESQUERDA;
break;
case CABECA_DIREITA:
posicao_inicial_x = x + 1;
posicao_inicial_y = y;
direcao_inicial = DIREITA;
break;
} // switch(temp[x])
} // else
} // for(x = 0; x <= 27; x++)
} // while(!feof(tabuleiro_arq))
}