Skip to content

Commit 90da64b

Browse files
committed
Spread loot to surrounding spaces
Instead of grouping loot into a sack it will now be "dropped" randomly to surrounding spaces around the monster. To facilitate this sprite interpolation has been added to the engine. Sprites can be interpolated for position, dimension and rotation. Introduces loot.c/loot.h which handle loot placement and drops. All dropped items now interpolate to their destination. Documentation for position functions has been updated and the function artifact_update has been introduced. Sound effects have been added to most item drops. Adds debug.c for easier manual testing utilities.
1 parent bec298e commit 90da64b

28 files changed

+583
-184
lines changed

assets/Sounds/FX/coin2.wav

282 KB
Binary file not shown.

assets/Sounds/FX/coin3.wav

87.7 KB
Binary file not shown.

assets/Sounds/FX/flesh_drop1.wav

118 KB
Binary file not shown.

assets/Sounds/FX/flesh_drop2.wav

112 KB
Binary file not shown.

assets/Sounds/FX/metal-small3.wav

130 KB
Binary file not shown.

assets/Sounds/FX/potion_drop.wav

146 KB
Binary file not shown.

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
file(GLOB SOURCE_FILES CONFIGURE_DEPENDS *.c)
22
target_sources(${PROJECT_NAME} PRIVATE ${SOURCE_FILES})
33

4+
if (DEBUG_BUILD)
5+
target_sources(${PROJECT_NAME} PRIVATE debug/debug.c)
6+
endif ()
7+
48
if (STEAM)
59
target_sources(${PROJECT_NAME} PRIVATE steam/steamworks_api_wrapper.c)
610
endif ()

src/artifact.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ artifact_create_random(Player *p, Uint8 level)
198198
void
199199
artifact_add_price(Artifact *a, unsigned int price)
200200
{
201-
201+
202202
Sprite *sprite = sprite_util_create_text_sprite("GUI/SDS_8x8.ttf",
203203
8,
204204
C_YELLOW,
@@ -310,6 +310,16 @@ artifact_copy(const Artifact *a)
310310
return new;
311311
}
312312

313+
void
314+
artifact_update(Artifact *a, UpdateData *ud)
315+
{
316+
sprite_update(a->sprite, ud);
317+
if (a->priceSprite)
318+
a->priceSprite->pos = a->sprite->pos;
319+
if (a->levelSprite)
320+
a->levelSprite->pos = a->sprite->pos;
321+
}
322+
313323
void
314324
artifact_render(Artifact *a, Camera *cam)
315325
{
@@ -319,11 +329,9 @@ artifact_render(Artifact *a, Camera *cam)
319329
pos.y += 4;
320330
particle_engine_sparkle(pos, DIM(24, 24), C_PURPLE, false);
321331
if (a->priceSprite) {
322-
a->priceSprite->pos = a->sprite->pos;
323332
sprite_render(a->priceSprite, cam);
324333
}
325334
if (a->levelSprite) {
326-
a->levelSprite->pos = a->sprite->pos;
327335
sprite_render(a->levelSprite, cam);
328336
}
329337
}

src/artifact.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ artifact_create(MagicalEffect);
6868
Artifact *
6969
artifact_copy(const Artifact*);
7070

71+
void
72+
artifact_update(Artifact*, struct UpdateData*);
73+
7174
void
7275
artifact_render(Artifact*, Camera*);
7376

src/item.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ item_create(void)
3232
item->collected = false;
3333
item->openable = false;
3434
item->opened = false;
35-
m_strcpy(item->label, 50, "");
35+
memset(item->label, '\0', 50);
3636
item->price = 0.0;
3737
item->value = 0.0;
3838
item->items = NULL;
@@ -41,13 +41,16 @@ item_create(void)
4141
}
4242

4343
void
44-
item_update(Item *item)
44+
item_update(Item *item, UpdateData *ud)
4545
{
46+
sprite_update(item->sprite, ud);
47+
4648
LinkedList *subsprites = item->subsprites;
4749
while (subsprites != NULL) {
4850
Sprite *sprite = subsprites->data;
4951
sprite->pos = item->sprite->pos;
5052
sprite->pos.x += 15 - sprite->dim.width / 2;
53+
sprite_update(sprite, ud);
5154
subsprites = subsprites->next;
5255
}
5356
}

0 commit comments

Comments
 (0)