Skip to content

Commit 6e3e692

Browse files
committed
Partial solution to potions
Still some open questions on how they should work.
1 parent dfed896 commit 6e3e692

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

src/item_builder.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,39 @@ item_builder_build_key(unsigned int type)
196196
return item;
197197
}
198198

199+
static void
200+
pickup_bloodlust(Item *item, Player *player)
201+
{
202+
// TODO: Implement
203+
}
204+
205+
static void
206+
pickup_frost(Item *item, Player *player)
207+
{
208+
// TODO: Implement
209+
}
210+
211+
Item *
212+
item_builder_build_potion(PotionType type)
213+
{
214+
Item *item;
215+
216+
switch (type) {
217+
case BLOODLUST:
218+
item = create_item("Items/Potion.png",
219+
NULL,
220+
CLIP16(48, 32),
221+
pickup_bloodlust);
222+
case FROST:
223+
item = create_item("Items/Potion.png",
224+
NULL,
225+
CLIP16(96, 0),
226+
pickup_frost);
227+
}
228+
229+
return item;
230+
}
231+
199232
static Item *
200233
create_treasure(int current_level)
201234
{

src/item_builder.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ typedef enum {
4141
ITEM_COUNT
4242
} ItemKey;
4343

44+
typedef enum {
45+
FROST,
46+
BLOODLUST,
47+
} PotionType;
48+
4449
void
4550
item_builder_init(SDL_Renderer *);
4651

@@ -59,6 +64,9 @@ item_builder_build_treasure(Treasure type, double goldAmt);
5964
Item *
6065
item_builder_build_key(unsigned int type);
6166

67+
Item *
68+
item_builder_build_potion(PotionType type);
69+
6270
void
6371
item_builder_close(void);
6472

src/player.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ player_create(class_t class, Camera *cam)
547547

548548
memset(&player->skills,
549549
0, PLAYER_SKILL_COUNT * sizeof(Skill*));
550+
memset(&player->effects, 0, sizeof(PlayerEffects));
550551

551552
for (size_t i = 0; i < LAST_ARTIFACT_EFFECT; ++i)
552553
player->equipment.artifacts[i].level = 0;
@@ -682,6 +683,13 @@ player_hit(Player *p, unsigned int dmg)
682683
void
683684
player_render(Player *player, Camera *cam)
684685
{
686+
if (player->effects.iced) {
687+
SDL_SetTextureColorMod(player->sprite->textures[0]->texture, 94, 156, 255);
688+
}
689+
if (player->effects.blood_lust) {
690+
SDL_SetTextureColorMod(player->sprite->textures[0]->texture, 255, 25, 45);
691+
}
692+
685693
sprite_set_alpha(player->sprite, player->phase_count ? 150 : 255);
686694
sprite_render(player->sprite, cam);
687695

src/player.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ typedef struct PlayerStateData {
6767
bool shopOwnerKiller;
6868
} PlayerStateData;
6969

70+
typedef struct PlayerEffects {
71+
bool iced;
72+
bool blood_lust;
73+
uint8_t damage_multiplier;
74+
uint8_t damage_recution;
75+
} PlayerEffects;
76+
7077
typedef struct Player {
7178
Sprite *sprite;
7279
Stats stats;
@@ -84,6 +91,7 @@ typedef struct Player {
8491
Animation *swordAnimation;
8592
PlayerEquipment equipment;
8693
PlayerStateData stateData;
94+
PlayerEffects effects;
8795
} Player;
8896

8997
Player*

0 commit comments

Comments
 (0)