Untested phase code. Needs more work

This commit is contained in:
Linus Probert 2018-09-28 14:57:43 +02:00
parent 35c3be45e0
commit 742d6e2363
4 changed files with 15 additions and 8 deletions

View File

@ -103,6 +103,8 @@ action_spent(Player *p)
for (size_t i = 0; i < PLAYER_SKILL_COUNT; ++i) { for (size_t i = 0; i < PLAYER_SKILL_COUNT; ++i) {
if (p->skills[i] != NULL && p->skills[i]->resetCountdown > 0) if (p->skills[i] != NULL && p->skills[i]->resetCountdown > 0)
p->skills[i]->resetCountdown--; 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 static bool
player_has_collided(RoomSpace *space) player_has_collided(Player *p, RoomSpace *space)
{ {
if (space->occupied) if (space->occupied)
return true; 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 static bool
@ -213,7 +215,7 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
Position matrixPos = position_to_matrix_coords(&player->sprite->pos); Position matrixPos = position_to_matrix_coords(&player->sprite->pos);
RoomSpace *space = &matrix->spaces[matrixPos.x][matrixPos.y]; 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.x -= TILE_DIMENSION * (int)direction.x;
player->sprite->pos.y -= TILE_DIMENSION * (int)direction.y; player->sprite->pos.y -= TILE_DIMENSION * (int)direction.y;
@ -229,8 +231,10 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
else { else {
player_collect_items(player, space); player_collect_items(player, space);
player_pickup_artifacts(player, space); player_pickup_artifacts(player, space);
player_interact_objects(player, space); if (player->phase_count) {
player_interact_traps_and_pits(player, space); player_interact_objects(player, space);
player_interact_traps_and_pits(player, space);
}
return false; return false;
} }
} }
@ -472,6 +476,7 @@ player_create(class_t class, Camera *cam)
player->xp = 0; player->xp = 0;
player->gold = 0; player->gold = 0;
player->potion_sips = 0; player->potion_sips = 0;
player->phase_count = 0;
player->class = class; player->class = class;
player->state = ALIVE; player->state = ALIVE;
player->projectiles = linkedlist_create(); player->projectiles = linkedlist_create();
@ -506,7 +511,7 @@ player_create(class_t class, Camera *cam)
player->stats = (Stats) ROGUE_STATS; player->stats = (Stats) ROGUE_STATS;
player->skills[0] = skill_create(BACKSTAB, cam); player->skills[0] = skill_create(BACKSTAB, cam);
player->skills[1] = skill_create(TRIP, 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->skills[3] = skill_create(DAGGER_THROW, cam);
player->daggers = 10; player->daggers = 10;
break; break;
@ -596,6 +601,7 @@ player_hit(Player *p, unsigned int dmg)
void void
player_render(Player *player, Camera *cam) player_render(Player *player, Camera *cam)
{ {
sprite_set_alpha(player->sprite, player->phase_count ? 150 : 255);
sprite_render(player->sprite, cam); sprite_render(player->sprite, cam);
LinkedList *projectile = player->projectiles; LinkedList *projectile = player->projectiles;

View File

@ -71,6 +71,7 @@ typedef struct Player {
double gold; double gold;
PlayerStatData stat_data; PlayerStatData stat_data;
unsigned int potion_sips; unsigned int potion_sips;
unsigned int phase_count;
class_t class; class_t class;
state_t state; state_t state;
Skill *skills[PLAYER_SKILL_COUNT]; Skill *skills[PLAYER_SKILL_COUNT];

View File

@ -716,7 +716,7 @@ skill_create(enum SkillType t, Camera *cam)
skill = create_backstab(); skill = create_backstab();
skill->tooltip = tooltip_create(backstab_tooltip, cam); skill->tooltip = tooltip_create(backstab_tooltip, cam);
break; break;
case BLINK: case PHASE:
error("Skill %d not implemented", t); error("Skill %d not implemented", t);
return NULL; return NULL;
default: default:

View File

@ -35,7 +35,7 @@ enum SkillType {
SIP_HEALTH, SIP_HEALTH,
BACKSTAB, BACKSTAB,
TRIP, TRIP,
BLINK PHASE
}; };
typedef struct SkillData_t { typedef struct SkillData_t {