Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animate tiles marked as animated in tile_config.json #40342

Merged
merged 5 commits into from
May 11, 2020

Conversation

verate
Copy link
Contributor

@verate verate commented May 8, 2020

Summary

SUMMARY: Infrastructure "Tile animations can be defined in tile_config.json files"

Purpose of change

Animations can add information and atmosphere to the game. Tiny lights can blink, enemies can sway, icons can hover. This change allows tilesets to specify looping animations for individual tiles that will play during the player's turn.

Describe the solution

Tileset maintainers mark tile definitions with "animated": true and specify fg/bg sprite lists, with weight being overloaded to indicate the number of frames, at a standard rate of 60fps (example below). The game reads the json animated property into tile_type and uses the current time to determine which sprite image to render.

Describe alternatives you've considered

Some tiles use fg/bg to display different images based on the tile's in-world position, rather than based on the time. For monsters, the icon is based on some identifier. We could introduce some sort of two-dimensional weighed list to handle animations for such tiles, but this can be a future project.

Testing

Format the single-line tile_config file for Ultimate, find the t_console entry, and replace with:

{
	"id": "t_console",
	"animated": true,
	"fg": [
		{"weight": 50, "sprite": 2290},
		{"weight": 10, "sprite": 2285}
	]
},

Ensure animations are enabled. Find a console and confirm that its screen flickers. Must be a loose wire.

src/cata_tiles.cpp Outdated Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
Co-authored-by: Alexey Mostovoy <[email protected]>
@Fris0uman
Copy link
Contributor

How is this going to interact with the compose script?

@verate
Copy link
Contributor Author

verate commented May 9, 2020

How is this going to interact with the compose script?

Tile information is preserved by the compose script, and this should apply to this new animated flag (as it does to rotates and multitile). The flag would be added to the tile entry, the script would preserve it, and the game would read it from the output tile config.

src/cata_tiles.cpp Outdated Show resolved Hide resolved
@curstwist curstwist added [C++] Changes (can be) made in C++. Previously named `Code` SDL: Tiles / Sound Tiles visual interface and sounds. labels May 11, 2020
Copy link
Contributor

@ifreund ifreund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ifreund ifreund merged commit 2abca8f into CleverRaven:master May 11, 2020
@verate verate deleted the idle-animations branch May 12, 2020 02:15
@Fris0uman
Copy link
Contributor

Fris0uman commented May 13, 2020

could you explain this feature in TILESET.md please.
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/TILESET.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` SDL: Tiles / Sound Tiles visual interface and sounds.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants