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

feat: directional bullet animation #1681

Merged
merged 7 commits into from
Apr 18, 2023

Conversation

scarf005
Copy link
Member

@scarf005 scarf005 commented Jul 1, 2022

Summary

output
video

SUMMARY: Features "Directional bullet animation"

Purpose of change

Describe the solution

  • adds new sprite id "animation_bullet_normal_0deg" and "animation_bullet_normal_45deg" to handle directional bullets.
  • previous sprite id "animation_bullet_normal" will be used as fallback if these new keys aren't found.

Describe alternatives you've considered

  • determine bullet sprites by weapon category
  • move some lambdas into headers?
  • refactor int rota in cata_tiles.h into enums?
  • can SDL handle 45 degrees rotation? if then no need for diagonal sprites

Testing

spawned m16 and fired at zeds. was able to render directional bullets with new tilesets and legacy bullet with old tileset.

@scarf005 scarf005 changed the title Directional bullet animation [CR] Directional bullet animation Jul 2, 2022
@Coolthulhu Coolthulhu self-assigned this Jul 6, 2022
@Coolthulhu
Copy link
Member

One rather big problem: there is no fallback when the tile is not available and the tile is unavailable in current version of the UDP tileset.

The best way to solve this would be to fork boophis' tileset repo, add a tile there, compile the new tileset, then PR the compiled tileset - here or as a separate PR. Then PR the new tiles to tileset repo as well - having BN-only content won't break things, since it doesn't overwrite anything.

A minimal solution would be to provide fallbacks in all tilesets and tile config examples and manual addition of the new tiles to already-compile UDP. Still, the addition should be PR'd to the tileset repo as well, otherwise an attempt to update the tileset will remove the diagonals and have them show the "no tile found" tile.

@scarf005
Copy link
Member Author

scarf005 commented Jul 7, 2022

true, or how do you think about providing a hardcoded fallback for diagonal bullets first?

@Coolthulhu
Copy link
Member

Hardcoded fallback would require good documentation for modders/tileset makers to know how to override it. Core examples would be better.

@Coolthulhu Coolthulhu removed their assignment Jul 12, 2022
@scarf005 scarf005 marked this pull request as draft July 13, 2022 01:52
@scarf005 scarf005 changed the title [CR] Directional bullet animation Directional bullet animation Jul 13, 2022
@olanti-p
Copy link
Contributor

Is this still relevant?

  1. There's a merge conflict, but it's trivial
  2. There need to be either hardcoded fallback defined in C++ or dummy entries added to the tilesets so the bullets don't show up as symbols. The latter would be easier to implement, just find the entry in tileset's JSON that has "animation_bullet_normal" in it and extend it into an array [ "animation_bullet_normal", "animation_bullet_normal_diagonal" ] (or extend the existing array if there is one). This will make it use the same tile.
  3. I'm not sure about the state of Boophis' unpacked repo, but a PR there would look like this
    Add sprite for mi-go nerve clusters (BN) Theawesomeboophis/UndeadPeopleUnpacked#41
    It's basically a JSON entry that describes the tile and the small PNG, both placed in the proper folder.

@scarf005
Copy link
Member Author

yeah i'd love to see this get merged, will try continuing it tomorrow

@github-actions github-actions bot added the src changes related to source code. label Apr 1, 2023
@scarf005 scarf005 marked this pull request as ready for review April 1, 2023 03:28
@scarf005 scarf005 requested review from joveeater and Coolthulhu April 1, 2023 03:41
@scarf005
Copy link
Member Author

scarf005 commented Apr 2, 2023

the PR's ready. old bullet sprite is used as fallback if it cannot find angled ones from tileset.
i'm unhappy with the unnecessary lookups on every frame but i decided to keep it since

  1. lookups doesn't seem to be the bottleneck, the game literally searches for every single items with string key yet it keeps 60fps.
  2. refactoring looks like nightmare to begin with. maybe after build: yet another C++20 migration #2341 gets merged and remove overloading whatsoever with designated initializer lists.

@scarf005 scarf005 marked this pull request as draft April 4, 2023 23:19
@scarf005
Copy link
Member Author

scarf005 commented Apr 4, 2023

regression found, fallback searching logic always returns false, keeping it draft until fixed.

nevermind, i was using symlinked gfx directory and hadn't updated the tileset there.

@scarf005 scarf005 marked this pull request as ready for review April 5, 2023 00:48
@scarf005 scarf005 changed the title Directional bullet animation feat: directional bullet animation Apr 5, 2023
@scarf005 scarf005 requested a review from olanti-p April 13, 2023 12:03
src/animation.cpp Outdated Show resolved Hide resolved
src/cata_tiles.h Outdated Show resolved Hide resolved
src/cata_tiles.h Outdated Show resolved Hide resolved
src/cata_tiles.cpp Outdated Show resolved Hide resolved
@olanti-p
Copy link
Contributor

Fallback behavior works as expected.
Since updating UDP from Boophis'es repo is a bit problematic for now, I've pushed a patch to this PR that adds directional bullets to our own compiled version.

@scarf005 scarf005 requested a review from olanti-p April 17, 2023 13:24
@scarf005 scarf005 merged commit 9601bb2 into cataclysmbnteam:upload Apr 18, 2023
@scarf005 scarf005 deleted the bullet-rotation branch April 18, 2023 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve bullet animation
3 participants