diff --git a/Makefile b/Makefile index 6c735ca..25265d3 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ run: $(all) playtest: $(all) @LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./ ./_build/release/breakhack -.PHONY: run +.PHONY: playtest lint: @make lint -sC _build/debug diff --git a/assets/Extras/Artifacts.png b/assets/Extras/Artifacts.png new file mode 100644 index 0000000..3789039 Binary files /dev/null and b/assets/Extras/Artifacts.png differ diff --git a/src/artifact.c b/src/artifact.c index c4fa3b7..083c6d7 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -68,6 +68,11 @@ artifact_set_effect(Artifact *a, MagicalEffect effect) case SKILL_RADIUS: a->info.name = "Magic wand"; a->info.desc = "Your magic has greater reach"; + break; + case DAGGER_BOUNCE: + a->info.name = "Magnet"; + a->info.desc = "You are attractive to daggers"; + break; default: break; } @@ -81,7 +86,8 @@ static int WarriorArtifacts[] = { PUSH_BACK, // 4 FEAR_INDUCING, // 5 INCREASED_STUN, // 6 - CHARGE_THROUGH // 7 + DAGGER_BOUNCE, // 7 + CHARGE_THROUGH // 8 }; static int RogueArtifacts[] = { @@ -92,7 +98,8 @@ static int RogueArtifacts[] = { PUSH_BACK, // 4 FEAR_INDUCING, // 5 INCREASED_STUN, // 6 - PHASE_IMPROVEMENT // 7 + DAGGER_BOUNCE, // 7 + PHASE_IMPROVEMENT // 8 }; static int MageArtifacts[] = { @@ -103,7 +110,8 @@ static int MageArtifacts[] = { PUSH_BACK, // 4 FEAR_INDUCING, // 5 INCREASED_STUN, // 6 - SKILL_RADIUS // 7 + DAGGER_BOUNCE, // 7 + SKILL_RADIUS // 8 }; /* Not in play yet */ @@ -115,7 +123,8 @@ static int PaladinArtifacts[] = { PUSH_BACK, // 4 FEAR_INDUCING, // 5 INCREASED_STUN, // 6 - SKILL_RADIUS // 7 + DAGGER_BOUNCE, // 7 + SKILL_RADIUS // 8 }; /* Not in play yet */ @@ -127,7 +136,8 @@ static int EngineerArtifacts[] = { PUSH_BACK, // 4 FEAR_INDUCING, // 5 INCREASED_STUN, // 6 - PHASE_IMPROVEMENT // 7 + DAGGER_BOUNCE, // 7 + PHASE_IMPROVEMENT // 8 }; static void @@ -147,7 +157,7 @@ add_level_sprite(Artifact *a) Artifact * artifact_create_random(Player *p, Uint8 level) { - int option = get_random(7); + int option = get_random(8); int * artifactPool = NULL; if (p->class == ROGUE) @@ -239,6 +249,11 @@ artifact_sprite_for(MagicalEffect effect) sprite_set_texture(sprite, t, 0); sprite->clip = CLIP16(2*16, 0); break; + case DAGGER_BOUNCE: + t = texturecache_add("Extras/Artifacts.png"); + sprite_set_texture(sprite, t, 0); + sprite->clip = CLIP16(0, 0); + break; default: break; } diff --git a/src/artifact.h b/src/artifact.h index 2a550c2..b51b1cf 100644 --- a/src/artifact.h +++ b/src/artifact.h @@ -31,6 +31,7 @@ typedef enum MagicalEffect { CHARGE_THROUGH, PHASE_IMPROVEMENT, SKILL_RADIUS, + DAGGER_BOUNCE, LAST_ARTIFACT_EFFECT // Sentinel } MagicalEffect; diff --git a/src/projectile.c b/src/projectile.c index b5add49..9ce02ba 100644 --- a/src/projectile.c +++ b/src/projectile.c @@ -49,6 +49,7 @@ projectile_dagger_create(void) p->sprite->dim = (Dimension) { 32, 32 }; p->sprite->rotationPoint = (SDL_Point) { 16, 16 }; p->collisionCount = 0; + p->bounceCount = 0; memset(&p->processedSpaces, false, sizeof(p->processedSpaces[0][0]) * MAP_ROOM_WIDTH * MAP_ROOM_HEIGHT); @@ -130,6 +131,10 @@ projectile_update(Projectile *p, UpdateData *data) player_monster_kill_check(data->player, space->monster); alive = player_has_artifact(data->player, PIERCING_DAGGERS) > p->collisionCount; projectilePos = space->monster->sprite->pos; + } else { + p->bounceCount += 1; + vector2d_reverse(&p->velocity); + alive = p->bounceCount < player_has_artifact(data->player, DAGGER_BOUNCE); } mixer_play_effect(SWORD_HIT); diff --git a/src/projectile.h b/src/projectile.h index f835007..0e5ca78 100644 --- a/src/projectile.h +++ b/src/projectile.h @@ -36,6 +36,7 @@ typedef struct Projectile { Timer *lifetime; bool alive; Uint32 collisionCount; + Uint32 bounceCount; bool processedSpaces[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT]; void (*onRender)(struct Projectile*); } Projectile; diff --git a/src/vector2d.c b/src/vector2d.c index 3b4864a..67ed945 100644 --- a/src/vector2d.c +++ b/src/vector2d.c @@ -13,6 +13,13 @@ vector2d_is_opposite(Vector2d v1, Vector2d v2) || ((v1.x < 0 && v2.x > 0) ^ (v1.y < 0 && v2.y > 0)); } +void +vector2d_reverse(Vector2d *vec) +{ + vec->x *= -1; + vec->y *= -1; +} + Vector2d vector2d_to_direction(const Vector2d *vec) { diff --git a/src/vector2d.h b/src/vector2d.h index 149222e..b59b457 100644 --- a/src/vector2d.h +++ b/src/vector2d.h @@ -43,4 +43,7 @@ vector2d_is_opposite(Vector2d, Vector2d); Vector2d vector2d_to_direction(const Vector2d*); +void +vector2d_reverse(Vector2d*); + #endif // VECTOR2D_H_