-
Notifications
You must be signed in to change notification settings - Fork 10
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
Added wall slide support #15
Conversation
…behavior allows to modify signicifantly the velocity during wall jump using left and right functions. New config key const_wall_jump is by default set to false, so it doesn't change the legacy, but when set to true by user, it blocks possibility to alter a jump after bouncing from a wall. Added new state - wall_jump and thus added a function to get that information from platypus.
…tion - is_wall_jumping()
…n now handle wall slide with a mutable wall_slide_gravity, which simulates sliding slowly down a wall. It notifies game object about starting wall slide and user can check if it is_wall_sliding(). Added this possibility to the example project. Fixed collision rays in example's config. Added abort_wall_slide() when control keys are released. Updated readme with new functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Some formatting and grammar mainly.
@@ -108,6 +117,8 @@ Platypus will send messages for certain state changes so that scripts can react, | |||
print("Doing a double jump!") | |||
elseif message_id == platypus.JUMP then | |||
print("Jumping!") | |||
elseif message_id == platypus.WALL_SLIDE then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation. Use tabs.
platypus/platypus.lua
Outdated
-- apply wall slide gravity | ||
if state.current.wall_slide then | ||
platypus.velocity.y = platypus.velocity.y + platypus.wall_slide_gravity * dt | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra line
platypus/platypus.lua
Outdated
@@ -324,6 +346,11 @@ function M.create(config) | |||
elseif state.current.wall_contact and platypus.allow_wall_jump then | |||
state.current.wall_jump = true | |||
state.previous.wall_jump = true | |||
-- abort wall sliding when jumping from wall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call platypus.abort_wall slide() instead? Or skip the conditional check and set current+previous wall_slide to false
README.md
Outdated
@@ -79,6 +79,15 @@ Use `platypus.jump()` to perform a jump and `platypus.abort_jump()` to reduce th | |||
end | |||
end | |||
end | |||
|
|||
## Double jump, wall jump and wall slide | |||
Platypus supports double jumps when config.allow_double_jump is set to true. Then, it occurs automatically, when used jump() while already jumped up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change second sentence to "A double jump is performed automatically when a second jump is done before and up until reaching the apex of the first jump. It is not possible to performa a double jump when falling"
README.md
Outdated
## Double jump, wall jump and wall slide | ||
Platypus supports double jumps when config.allow_double_jump is set to true. Then, it occurs automatically, when used jump() while already jumped up. | ||
|
||
Platypus supports wall jumps when config.allow_wall_jump is set to true. Then, it occurs automatically, when used jump() while having a wall_contact. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change second sentence. "A wall jump is performed automatically when jumping while having wall contact while falling or wall sliding. The wall jump pushes the player out from the wall in question."
README.md
Outdated
Platypus supports wall jumps when config.allow_wall_jump is set to true. Then, it occurs automatically, when used jump() while having a wall_contact. | ||
Normally, user can alter your movement right after bounced from a wall, but when you set config.const_wall_jump - the bounce will be always the same and user won't be able to alter it. | ||
|
||
Platypus supports wall slide when config.allow_wall_slide is set to true. Then, it occurs automatically, when pushing toward a wall, while falling down. Platypus offers also to abort_wall_slide(), for example, when the control key is released, so user is no longer pushing toward the wall. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change second sentence. "A wall slide will be performed automatically when the player has wall contact while falling and moving (using platypus.left()
or platypus.right()
) in the direction of the wall."
Thanks for the review! I'll push a commit probably this evening ;) |
…ide() when wall jumping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review the comments on the documentation as well!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed one indentation issue but that's ok. I'll fix it! Thank you for your contribution!
Added wall slide support.
Platypus, when
config.allow_wall_slide
istrue
, can now handle wall slide with a mutableconfig.wall_slide_gravity
, which simulates sliding slowly down a wall. It notifies game object about starting wall slide with a messageplatypus.WALL_SLIDE
and user can check if itis_wall_sliding()
. Added this possibility to the example project. Fixed collision rays in example's config. Addedabort_wall_slide()
when control keys are released. Updated readme with new functionality informations and general double and wall jumps and wall slide.