Skip to content

Commit

Permalink
tr2/output: add support for animated sprites
Browse files Browse the repository at this point in the history
This uses the same logic as TR1 to allow sprites to be animated.

Resolves LostArtefacts#2401.
  • Loading branch information
lahm86 committed Jan 27, 2025
1 parent d15fb44 commit 1deee89
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- added the ability to hold left/right to move through menus more quickly (#2298)
- added the ability to disable exit fade effects alone (#2348)
- added a fade-out effect when completing Lara's Home
- added support for animated sprites (#2401)
- changed default input bindings to let the photo mode binding be compatible with TR1X:
| Key | Old binding | New binding |
| ----------------------------- | ----------- | ------------ |
Expand Down
1 change: 1 addition & 0 deletions docs/tr2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ game with new enhancements and features.
- added ability to toggle between the software/hardware renderer at runtime
- added optional fade effects to the hardware renderer
- added text information when changing rendering options at runtime
- added support for animated sprites
- changed the hardware renderer to always use 16-bit textures
- changed the software renderer to use the picture's palette for the background pictures
- changed fullscreen behavior to use windowed desktop mode
Expand Down
15 changes: 15 additions & 0 deletions src/tr2/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,21 @@ void Output_DoAnimateTextures(const int32_t ticks)
g_ObjectTextures[range->textures[i]] = temp;
range = range->next_range;
}

for (int32_t i = 0; i < MAX_STATIC_OBJECTS; i++) {
const STATIC_OBJECT_2D *const object = Object_GetStaticObject2D(i);
if (!object->loaded || object->frame_count == 1) {
continue;
}

const int16_t frame_count = object->frame_count;
const SPRITE_TEXTURE temp = g_SpriteTextures[object->texture_idx];
for (int32_t j = 0; j < frame_count - 1; j++) {
g_SpriteTextures[object->texture_idx + j] =
g_SpriteTextures[object->texture_idx + j + 1];
}
g_SpriteTextures[object->texture_idx + frame_count - 1] = temp;
}
m_TickComp -= TICKS_PER_FRAME * 5;
}
}
Expand Down

0 comments on commit 1deee89

Please sign in to comment.