Completes buyable items
This commit is contained in:
parent
16d9035941
commit
7b47c6a6bf
11
src/item.c
11
src/item.c
|
@ -46,8 +46,13 @@ item_render(Item *item, Camera *cam)
|
|||
sprite_render(item->sprite, cam);
|
||||
|
||||
LinkedList *subsprites = item->subsprites;
|
||||
while (subsprites)
|
||||
sprite_render(linkedlist_pop(&subsprites), cam);
|
||||
while (subsprites != NULL) {
|
||||
Sprite *sprite = subsprites->data;
|
||||
sprite->pos = item->sprite->pos;
|
||||
sprite->pos.x + 15 - sprite->dim.width / 2;
|
||||
sprite_render(sprite, cam);
|
||||
subsprites = subsprites->next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -75,7 +80,7 @@ item_collected(Item *item, Player *player)
|
|||
if (item->price) {
|
||||
player->gold -= item->price;
|
||||
char costLabel[10];
|
||||
m_sprintf(costLabel, 10, "-%d", item->price);
|
||||
m_sprintf(costLabel, 10, "-$%.0f", item->price);
|
||||
actiontextbuilder_create_text(costLabel, C_YELLOW, &player->sprite->pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,14 +108,14 @@ create_priced_item(double price, const char *path0, const char *path1, SDL_Rect
|
|||
Sprite *priceSprite = sprite_create();
|
||||
sprite_load_text_texture(priceSprite, "GUI/SDS_8x8.ttf", 0, 8, 1);
|
||||
char priceLabel[10];
|
||||
m_sprintf(priceLabel, 10, "%d", item->price);
|
||||
m_sprintf(priceLabel, 10, "$%.0f", item->price);
|
||||
texture_load_from_text(priceSprite->textures[0],
|
||||
priceLabel,
|
||||
C_YELLOW,
|
||||
C_BLACK,
|
||||
builder->renderer);
|
||||
|
||||
priceSprite->pos = item->sprite->pos;
|
||||
priceSprite->dim = priceSprite->textures[0]->dim;
|
||||
linkedlist_append(&item->subsprites, priceSprite);
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -516,6 +516,7 @@ player_create(class_t class, Camera *cam)
|
|||
player->animationTimer = _timer_create();
|
||||
player->swordAnimation = animation_create(5);
|
||||
player->equipment.hasArtifacts = false;
|
||||
player->stateData.shopOwnerKiller = false;
|
||||
|
||||
build_sword_animation(player, cam->renderer);
|
||||
|
||||
|
|
|
@ -62,6 +62,10 @@ typedef struct PlayerEquipment {
|
|||
bool hasArtifacts;
|
||||
} PlayerEquipment;
|
||||
|
||||
typedef struct PlayerStateData {
|
||||
bool shopOwnerKiller;
|
||||
} PlayerStateData;
|
||||
|
||||
typedef struct Player {
|
||||
Sprite *sprite;
|
||||
Stats stats;
|
||||
|
@ -78,6 +82,7 @@ typedef struct Player {
|
|||
Timer *animationTimer;
|
||||
Animation *swordAnimation;
|
||||
PlayerEquipment equipment;
|
||||
PlayerStateData stateData;
|
||||
} Player;
|
||||
|
||||
Player*
|
||||
|
|
Loading…
Reference in New Issue