-
Notifications
You must be signed in to change notification settings - Fork 0
/
move.c
36 lines (32 loc) · 1.23 KB
/
move.c
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
#include "dictionary.h"
// Verifica se há uma arma nas coordenadas especificadas (x, y) no mapa
int verifyWeapon(STATE *st, char map[st->height][st->width], int x, int y, STATEweapons stWeapons[]){
for (int i = 0; i < NUM_WEAPONS; i++){
if(map[st->playerY+y][st->playerX+x] == stWeapons[i].id){
return 1;
}
}
return 0;
}
// Verifica se há uma poção nas coordenadas especificadas (x, y) no mapa
int verifyPotion(STATE *st, char map[st->height][st->width], int x, int y, STATEpotions stPotions[]){
for (int i = 0; i < NUM_POTIONS; i++){
if(map[st->playerY+y][st->playerX+x] == stPotions[i].id){
return 1;
}
}
return 0;
}
// Verifica se o movimento nas coordenadas (x, y) é válido
int verifyMove(STATE *st, char map[st->height][st->width], int x, int y, STATEweapons stWeapons[], STATEpotions stPotions[]){
if(map[st->playerY+y][st->playerX+x] == *FLOOR ||
map[st->playerY+y][st->playerX+x] == *DOOR_UNLOCK ||
map[st->playerY+y][st->playerX+x] == *KEY ||
map[st->playerY+y][st->playerX+x] == *COIN ||
verifyWeapon(st, map, x, y, stWeapons) ||
verifyPotion(st, map, x, y, stPotions)
){
return 1;
}
return 0;
}