From 2dc25c9b539c79889c278726f4fb106b9b3ed627 Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Wed, 15 May 2019 20:32:48 +0200 Subject: [PATCH] Adds the DAGGER_MAGNET artifact * Adds sprites for volotile and synamite as well --- Makefile | 2 +- assets/Extras/Artifacts.png | Bin 0 -> 548 bytes src/artifact.c | 27 +++++++++++++++++++++------ src/artifact.h | 1 + src/projectile.c | 5 +++++ src/projectile.h | 1 + src/vector2d.c | 7 +++++++ src/vector2d.h | 3 +++ 8 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 assets/Extras/Artifacts.png 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 0000000000000000000000000000000000000000..37890390810b0b6f45359b5617e289fdb7587702 GIT binary patch literal 548 zcmV+<0^9wGP)Px$-bqA3R7i>Kl`)GGK@`V-n_Y$!Q+N`zIS@g%*lUEdu&@zK5x6T;< z%^|d|<;GjBR~%WVwE%5nXdA=e;)2h{I2SPNB()$u%x2lz6(T6xXdAN}R%->{2V*K* zY-p{=$q%8E&^y}U1la%jI4dMRihpa3Q}CEh1*Kp%V=o9Yh^lrf1-OoWg?Rot;nn+_ zjJ|y;Eu;p70NzFbQi#!)EuoWe_t9;qoH|Z;P###vA+?;v&^}A!YUnAt&2}mw4Ias=|;^0Q^fij(&GcONSrL;vqPN#(P mQ1J|uwZnKkcG~~1Yv?CshVG&ymJ&?>0000info.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_