Smooths out some glitches
Don't move dead monsters. Don't run player and monster turn in one frame. Fixes a bad "position_in_room" check.
This commit is contained in:
parent
d983318453
commit
1bea221369
|
@ -476,11 +476,11 @@ run_game(void)
|
|||
currentTurn = MONSTER;
|
||||
player_reset_steps(gPlayer);
|
||||
}
|
||||
}
|
||||
if (currentTurn == MONSTER) {
|
||||
if (map_move_monsters(gMap, gRoomMatrix))
|
||||
} else if (currentTurn == MONSTER) {
|
||||
if (map_move_monsters(gMap, gRoomMatrix)) {
|
||||
currentTurn = PLAYER;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(gRenderer, 0, 0, 0, 0);
|
||||
SDL_RenderClear(gRenderer);
|
||||
|
|
|
@ -102,7 +102,6 @@ map_clear_dead_monsters(Map *map, Player *player)
|
|||
while (map->monsters) {
|
||||
Monster *monster = linkedlist_pop(&map->monsters);
|
||||
if (monster->stats.hp <= 0) {
|
||||
// Loot drops
|
||||
monster_drop_loot(monster, map, player);
|
||||
monster_destroy(monster);
|
||||
} else {
|
||||
|
@ -147,6 +146,8 @@ map_move_monsters(Map *map, RoomMatrix *rm)
|
|||
while (m) {
|
||||
Monster *monster = m->data;
|
||||
m = m->next;
|
||||
if (monster->stats.hp <= 0)
|
||||
continue;
|
||||
if (!position_in_room(&monster->sprite->pos, &map->currentRoom))
|
||||
continue;
|
||||
allDone = allDone && monster_move(monster, rm);
|
||||
|
|
|
@ -78,5 +78,5 @@ bool position_in_room(Position *pos, Position *roomPos)
|
|||
bool
|
||||
position_in_roommatrix(const Position *pos)
|
||||
{
|
||||
return pos->x >= 0 && pos->x < MAP_ROOM_WIDTH && pos->y > 0 && pos->y < MAP_ROOM_HEIGHT;
|
||||
return pos->x >= 0 && pos->x < MAP_ROOM_WIDTH && pos->y >= 0 && pos->y < MAP_ROOM_HEIGHT;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue