HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.93k stars 427 forks source link

Allow linear drag and max speed, drag on skid #3110

Open Geokureli opened 2 months ago

Geokureli commented 2 months ago

Attempt number 2 at #2704:

Allow linear drag and max speed

Meaning it's calculated based on velocity's magnitude rather than the individual x/y speed. New fields: dragMode and maxSpeedMode

Examples

// old code
// drag.x = drag.y = 800;
// maxVelocity.x = maxVelocity.y = SPEED; // possible to go SPEED * sqrt(2)

// new code
dragMode = XY(800, 800); // behaves identical to old code
maxSpeedMode = LINEAR(SPEED); // impossible to go faster than SPEED

Drag on skid

New field dragApplyMode: INERTIAL - old behavior where drag is applied when acceleration is 0 ALWAYS - drag is always applied SKID - drag is applied when inertial or decelerating

TO DO