Untested phase code. Needs more work
This commit is contained in:
parent
35c3be45e0
commit
742d6e2363
18
src/player.c
18
src/player.c
|
@ -103,6 +103,8 @@ action_spent(Player *p)
|
|||
for (size_t i = 0; i < PLAYER_SKILL_COUNT; ++i) {
|
||||
if (p->skills[i] != NULL && p->skills[i]->resetCountdown > 0)
|
||||
p->skills[i]->resetCountdown--;
|
||||
if (p->phase_count > 0)
|
||||
p->phase_count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,12 +196,12 @@ player_interact_traps_and_pits(Player *player, RoomSpace *space)
|
|||
}
|
||||
|
||||
static bool
|
||||
player_has_collided(RoomSpace *space)
|
||||
player_has_collided(Player *p, RoomSpace *space)
|
||||
{
|
||||
if (space->occupied)
|
||||
return true;
|
||||
|
||||
return space->monster && space->monster->sprite->state != SPRITE_STATE_FALLING;
|
||||
return !p->phase_count && space->monster && space->monster->sprite->state != SPRITE_STATE_FALLING;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -213,7 +215,7 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
|
|||
Position matrixPos = position_to_matrix_coords(&player->sprite->pos);
|
||||
RoomSpace *space = &matrix->spaces[matrixPos.x][matrixPos.y];
|
||||
|
||||
if (player_has_collided(space)) {
|
||||
if (player_has_collided(player, space)) {
|
||||
player->sprite->pos.x -= TILE_DIMENSION * (int)direction.x;
|
||||
player->sprite->pos.y -= TILE_DIMENSION * (int)direction.y;
|
||||
|
||||
|
@ -229,8 +231,10 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
|
|||
else {
|
||||
player_collect_items(player, space);
|
||||
player_pickup_artifacts(player, space);
|
||||
player_interact_objects(player, space);
|
||||
player_interact_traps_and_pits(player, space);
|
||||
if (player->phase_count) {
|
||||
player_interact_objects(player, space);
|
||||
player_interact_traps_and_pits(player, space);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -472,6 +476,7 @@ player_create(class_t class, Camera *cam)
|
|||
player->xp = 0;
|
||||
player->gold = 0;
|
||||
player->potion_sips = 0;
|
||||
player->phase_count = 0;
|
||||
player->class = class;
|
||||
player->state = ALIVE;
|
||||
player->projectiles = linkedlist_create();
|
||||
|
@ -506,7 +511,7 @@ player_create(class_t class, Camera *cam)
|
|||
player->stats = (Stats) ROGUE_STATS;
|
||||
player->skills[0] = skill_create(BACKSTAB, cam);
|
||||
player->skills[1] = skill_create(TRIP, cam);
|
||||
player->skills[2] = skill_create(BLINK, cam);
|
||||
player->skills[2] = skill_create(PHASE, cam);
|
||||
player->skills[3] = skill_create(DAGGER_THROW, cam);
|
||||
player->daggers = 10;
|
||||
break;
|
||||
|
@ -596,6 +601,7 @@ player_hit(Player *p, unsigned int dmg)
|
|||
void
|
||||
player_render(Player *player, Camera *cam)
|
||||
{
|
||||
sprite_set_alpha(player->sprite, player->phase_count ? 150 : 255);
|
||||
sprite_render(player->sprite, cam);
|
||||
|
||||
LinkedList *projectile = player->projectiles;
|
||||
|
|
|
@ -71,6 +71,7 @@ typedef struct Player {
|
|||
double gold;
|
||||
PlayerStatData stat_data;
|
||||
unsigned int potion_sips;
|
||||
unsigned int phase_count;
|
||||
class_t class;
|
||||
state_t state;
|
||||
Skill *skills[PLAYER_SKILL_COUNT];
|
||||
|
|
|
@ -716,7 +716,7 @@ skill_create(enum SkillType t, Camera *cam)
|
|||
skill = create_backstab();
|
||||
skill->tooltip = tooltip_create(backstab_tooltip, cam);
|
||||
break;
|
||||
case BLINK:
|
||||
case PHASE:
|
||||
error("Skill %d not implemented", t);
|
||||
return NULL;
|
||||
default:
|
||||
|
|
|
@ -35,7 +35,7 @@ enum SkillType {
|
|||
SIP_HEALTH,
|
||||
BACKSTAB,
|
||||
TRIP,
|
||||
BLINK
|
||||
PHASE
|
||||
};
|
||||
|
||||
typedef struct SkillData_t {
|
||||
|
|
Loading…
Reference in New Issue