thousands-state-46635
02/27/2023, 12:57 AMthousands-state-46635
02/27/2023, 12:58 AMthousands-state-46635
02/27/2023, 12:58 AMthousands-state-46635
02/27/2023, 12:58 AMn - n * factorthousands-state-46635
02/27/2023, 1:16 AMhallowed-ocean-84954
02/27/2023, 1:25 AMn - n * factor ? And is factor > or < 1.0 ? And what is the range of values of n ?thousands-state-46635
02/27/2023, 1:27 AMthousands-state-46635
02/27/2023, 1:27 AMthousands-state-46635
02/27/2023, 1:27 AMthousands-state-46635
02/27/2023, 1:27 AMhx
if (controls.binds['left'].pressed())
{
if (direction == RIGHT && character.velocity.x > 20)
{
character.velocity.x -= MathUtil.damp(character.velocity.x, .8);
// trace('okb', character.velocity.x);
}
else
{
character.velocity.x = -speed;
direction = LEFT;
}
}
else if (controls.binds['right'].pressed())
{
if (direction == LEFT && character.velocity.x < 20)
{
character.velocity.x += MathUtil.damp(character.velocity.x, .8);
// trace('okc', character.velocity.x);
}
else
{
character.velocity.x = speed;
direction = RIGHT;
}
}
else
{
direction = NONE;
character.velocity.x = 0;
}thousands-state-46635
02/27/2023, 1:28 AMthousands-state-46635
02/27/2023, 1:28 AMthousands-state-46635
02/27/2023, 1:29 AMhx
// MathUtil.damp()
public static inline function damp(n:Float, factor:Float)
{
return n - n * factor;
}thousands-state-46635
02/27/2023, 1:30 AMthousands-state-46635
02/27/2023, 1:30 AMhallowed-ocean-84954
02/27/2023, 1:35 AMwitty-island-52596
02/27/2023, 1:49 AMwitty-island-52596
02/27/2023, 1:50 AMwitty-island-52596
02/27/2023, 1:51 AMwitty-island-52596
02/27/2023, 1:52 AMwitty-island-52596
02/27/2023, 1:54 AMhallowed-ocean-84954
02/27/2023, 2:14 AMwitty-island-52596
02/27/2023, 2:39 AMhallowed-ocean-84954
02/27/2023, 2:41 AMwitty-island-52596
02/27/2023, 2:43 AMwitty-island-52596
02/27/2023, 2:43 AMwitty-island-52596
02/27/2023, 2:44 AMhallowed-ocean-84954
02/27/2023, 2:44 AMwitty-island-52596
02/27/2023, 3:07 AMhallowed-ocean-84954
02/27/2023, 3:09 AM