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

Various improvements to Motion system #884

Merged
merged 6 commits into from Apr 11, 2015

Conversation

mucaho
Copy link
Contributor

@mucaho mucaho commented Mar 17, 2015

Continuation of #876

  • Change units in motion system to use user intuitive pixels per frame and degrees per frame
    Now when user sets vx = 1, the entity will move 1px each frame, depending on the current target fps Crafty.timer.FPS(). Note that this should also work in the cases when user selects different timer.stepMode (e.g. variable), as the calculation is still done using dt and a dtFactor derived from the desired target FPS.
  • Fixes bug that when setting gravityConst before activating gravity() leads to inconsistent state
  • Fixes bug that leads to incosistent state when entity intersects with multiple ground entities
  • Small improvements Supportable, Twoway and Multiway
  • Add additional tests

Future additions

  • Allow Supportable to check for SAT collision (see discussion). However, what to do about entity snapping? this.y = hit._y - this._h; // snap entity to ground object.
    As you can see, this won't snap correctly with the polygon hitbox being larger/smaller than the actual entity. Should the user be allowed to specify his own snap function?
  • I think we should limit the downwards velocity when gravity is active (introduce settable terminal velocity that defaults to the velocity caused by gravity after 12 frames) and document for user that he should make his platforms at least terminal velocity + 1 high - max(entity._h, platform._h) > terminal velocity

The motion system uses non-user friendly conversion between pixels
and the metric system. This commit changes all values to be in
pixels/frame and degrees/frame so that the user can easily access
and modify motion values without the need of external or internal
conversion between the units of measurement.
This commit also introduces the "FPSChange" event.
Make Twoway and Fourway constructors callable without parameters.
Simplify and streamline Twoway implementation.
When gravity constant is changed before gravity is started,
an invalid gravity state occurs. This commit fixes this case.
@mucaho mucaho force-pushed the fix_pxpermeters branch 3 times, most recently from 35820e5 to 3fa32d0 Compare March 21, 2015 13:55
Improve docs of Supportable and Twoway with examples of realistic,
custom land and jump behavior.
Fix bug occurring when multiple ground entities overlap the entitiy,
which leads to problems registering the actual ground entity.
Make ground property have property getter accessor rather than a
custom function.
Streamline ground detection to match Collision.hit implementation.
@mucaho
Copy link
Contributor Author

mucaho commented Apr 11, 2015

The contents of this patch have been tested in practice and are part of implementing the Motion system, so going ahead and merging this.

mucaho pushed a commit that referenced this pull request Apr 11, 2015
Various improvements to Motion system
@mucaho mucaho merged commit c446931 into craftyjs:develop Apr 11, 2015
@mucaho mucaho deleted the fix_pxpermeters branch April 11, 2015 11:21
@mucaho mucaho mentioned this pull request May 16, 2015
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

2 participants