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

Move dart's sprite action initialisation to the constructor(s) #2567

Merged
merged 2 commits into from
Aug 4, 2023

Conversation

Narre
Copy link
Contributor

@Narre Narre commented Aug 2, 2023

Since the dart's direction is already known at the time of the Dart object being created, there's no reason the sprite action shouldn't be initialised in the constructor. This fixes an oversight from #2554 where the dart's position when spawning from a DartTrap is calculated from the sprite before its proper action is set, resulting in the maths not being correct for three of the four directions. I didn't notice this before since the dart is only spawned off by a few pixels, but it would be a bigger problem for custom dart sprites. Moving the sprite action to the constructor(s) fixes this, since the sprite action is already set properly at the time the dart's position is calculated when being shot out of a DartTrap.

EDIT: Alternatively, I could keep the sprite action initialisation in Dart::initialize() and set the action manually in DartTrap::fire() before Dart::initialize() is called. That would fix the problem too. Whichever you think is better.

@Rusty-Box Rusty-Box merged commit ecb9350 into SuperTux:master Aug 4, 2023
33 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants