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

Support for easing on any path object #1507

Merged
merged 12 commits into from Aug 17, 2020
Merged

Support for easing on any path object #1507

merged 12 commits into from Aug 17, 2020

Conversation

Semphriss
Copy link
Member

Instead of the mandatory flat linear movement, platforms and tilemaps can now move at varying speed more easily with easing!

Demo : https://youtu.be/gmWf3KeeiSs

supertux_easing

@mbernard2
Copy link
Contributor

Everything works fine with the "platform" object, but not with moving tilemaps.

There are a few problems when Tux in standing on a downwards-accelerating platform (as a tilemap). Sometimes, Tux tends to move "into" the platform, and eventually either jumps or dies. However, this is a known issue regarding moving platforms, and is related to issue #401 on which I've been working lately. In other words: it doesn't have to be fixed in this PR.

There's just one comment I would make: I suggest you remove the "elastic" mode, because Tux either goes right through it or gets killed by it (when it's slower), so it's pretty useless:

2    2 5

Apart from that, I made recordings of the other bugs I've seen, but again, the fundamental problem here is the collision mechanism. I'm about to write a fix for that and submit a PR soon. I don't know if it should be merged in the meantime (as it doesn't affect platform objects), or if we should wait for #401 to be fixed. @tobbi @weluvgoatz, what do you guys thinks ?

But anyway, here's what went wrong:

  • Tux getting "into" the platform by a few pixels, than jumping by itself:
    1

  • Tux getting killed by a platform that moves down too fast:
    3

  • Same as before, but this time the platform is moving up:
    4

  • Same as the first, but Tux is on a slowly accelerating platform:
    5

@Semphriss
Copy link
Member Author

Ah, that's problematic.

I'd still like to retain easing as it can be used correctly if, for example, it is used on non-solid tilemaps or on solid tilemaps on which Tux can't be standing when it moves (like a tile-based door that only moves during a scripted animation).

But I get your point, it can easily be misused and it's not necessarily obvious to an unexperienced or unaware level designer, and it can be a very frustrating bug to encounter as a player.

I can make a few temporary changes while the bug is being fixed :

  • Show a warning dialog to the user when changing the easing mode of a tilemap to anything else than "No easing"
  • Only show the most common easing modes (those that are known for not causing problems) and add an option to show all of them; when the player would activate it, it'd display a warning instructing the designer to use those easings with care.
  • Temporarily forbid easing on solid tilemaps (and display a warning when setting an easing for a solid tilemap)

Would any of them be useful?

Also, if you want some help to fix that bug, I'm all in :)

@tobbi
Copy link
Member

tobbi commented Aug 15, 2020

You forgot one option:

  1. Changing our collision detection code so it works with the changes. Have fun with that ;)

@Semphriss
Copy link
Member Author

You forgot one option:

1. Changing our collision detection code so it works with the changes. Have fun with that ;)

@mbernard2 said he was working on it; Imma wait for his reply, so we don't do the same fix twice :)

@maxteufel
Copy link
Member

I think the included files are "small" enough to be put in an appropriate subdirectory of src/ (perhaps they should go into src/math/) rather than external/, similar to how we have src/addon/md5.[ch]pp.

@Semphriss
Copy link
Member Author

That's true, plus the files have been heavily modified, and I never managed to find how to include them without typing "#include "../external..."" so it would be good if I moved it to src/math. I'll ask around a bit, and if people approve it I'll do that!

double BounceEaseInOut(double p);

typedef double(*easing)(double);
easing getEasingByName(EasingMode ease_type);
Copy link
Member

@tobbi tobbi Aug 16, 2020

Choose a reason for hiding this comment

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

change the signature to getEasingByName(const EasingMode& easy_type)


typedef double(*easing)(double);
easing getEasingByName(EasingMode ease_type);
const char* getEasingName(EasingMode ease_type);
Copy link
Member

Choose a reason for hiding this comment

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

Here accordingly.


}

EasingMode EasingMode_from_string(std::string ease_name);
Copy link
Member

Choose a reason for hiding this comment

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

...and here as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I corrected the signatures in easing.cpp and easing.hpp, GCC told me nothing else had to be changed (it didn't print any warning). I'll wait for the current build to finish, so that if there's any other error clang finds, I'll correct it in the same commit to save some time.

@weluvgoatz weluvgoatz merged commit 7674ff6 into SuperTux:master Aug 17, 2020
mbernard2 pushed a commit to mbernard2/supertux that referenced this pull request Aug 18, 2020
* Support for easing on any path object (platforms, tilemaps, etc.)

* Attempt #1 to fix Travis build errors (easing)

* Attempt #2 at fixing the Travis build (easing)

* Remade the easing system with a WTFPL-Licensed library

* Fixed the double-to-flat implicit conversions in easing

* Changed 'std::string' with 'const char*' in C-linked functions in easing

* Reordered easing methods so that the names actually match the easing functions

* Moved easing to src/math

* Fixed include paths, oops

* Fixed some magic includes

* Deleted unreachable code in easing.cpp

* Improved coding style and fixed building problem on macOS

Co-authored-by: Semphris <invalid@example.com>
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.

None yet

5 participants