void checkPlayerLife(Player *player, App *app){ if(player->body.life > PLAYER_HEALTH) player->body.life = PLAYER_HEALTH; if(app->game.winner){ if(player != app->game.winner){ player->body.action = ACTION_DEATH; if(player->body.life > 0){ player->body.life -= 0.08; } } } else if(player->body.action == ACTION_DEATH && app->game.head.body.life > 0){ player->grabbing = 0; player->special_attack = 0; if( player->body.life <= PLAYER_HEALTH ) { player->body.life += 0.05; if(player->body.life > PLAYER_HEALTH) { player->body.life = PLAYER_HEALTH; player->body.action = ACTION_MOVE; playWakeup(); } } } else if(player->body.life <= 0) { playerDie(app, player); } }
char* playerMove(player* pl, DIR a, player* w){ char* msg = ""; int8_t x0 = pl->pos->x + DIRECTIONS[a].x; int8_t y0 = pl->pos->y + DIRECTIONS[a].y; point p = {x0, y0}; if(inBounds(&p)){ switch(grid[x0][y0].object){ case WUMPUS: printf("You have been eaten by the wumpus!\n"); playerDie(pl, w); break; case PIT: printf("You fell down a pit!\n"); playerDie(pl, w); break; case BAT: msg = "Bats carried you away!\n"; rmObj(pl->pos); grid[pl->pos->x][pl->pos->y].explored = 1; pl->pos = getEmptyPoint(); placeObj(pl->pos, PLAYER); break; case ARROW: msg = "You found an arrow!\n"; pl->arrows++; default: grid[pl->pos->x][pl->pos->y].object = OBJECTS[EXPLORED].type; grid[pl->pos->x][pl->pos->y].explored = 1; pl->pos->x = x0; pl->pos->y = y0; grid[pl->pos->x][pl->pos->y].object = OBJECTS[PLAYER].type; grid[pl->pos->x][pl->pos->y].explored = 1; break; } } return msg; }