Merge branch 'main' of https://git.main.qwsdcvghyu.com/riley/wrplat-godot
Release / Export Game (push) Successful in 1m31s
Release / Export Game (push) Successful in 1m31s
This commit is contained in:
@@ -45,6 +45,10 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
private float MaxRunSpeed { get; set; } = 16f;
|
||||
[Export]
|
||||
private float MaxWalkSpeed { get; set; } = 8f;
|
||||
[Export]
|
||||
private float MaxAirSpeed { get; set; } = 16f;
|
||||
[Export]
|
||||
private float MaxDoubleJumpFallSpeed { get; set; } = 1f;
|
||||
|
||||
[ExportCategory("Objects")]
|
||||
[Export]
|
||||
@@ -75,7 +79,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
[Export]
|
||||
public float Deadzone { get; set; } = 0.1f;
|
||||
|
||||
|
||||
public float GetMinAccel(float delta) => CancellationAcceleration * delta;
|
||||
|
||||
|
||||
private float _lv = 0.0f;
|
||||
@@ -135,8 +139,6 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
float velx = (Velocity.X / UnitToPx);
|
||||
float vely = (Velocity.Y / UnitToPx) + Gravity * (float)delta;
|
||||
|
||||
if (Mathf.Abs(velx) < 0.1) velx = 0;
|
||||
|
||||
var grounded = this.IsOnFloor();
|
||||
var coyoteGrounded = _timeOffGround < CoyoteTiming;
|
||||
if (grounded || coyoteGrounded) {
|
||||
@@ -205,7 +207,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("jump") && Mathf.Abs(vely) < 2) {
|
||||
if (Input.IsActionJustPressed("jump") && Mathf.Abs(vely) < MaxDoubleJumpFallSpeed) {
|
||||
EmitSignal(SignalName.OnJump, (int)JumpKind.Midair, this.IsOnFloor(), this.IsOnWall());
|
||||
vely = -_lv;
|
||||
}
|
||||
@@ -219,16 +221,13 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
else velx += autostop;
|
||||
}
|
||||
|
||||
var maxXSpeed = Input.IsActionPressed("run") ? MaxRunSpeed : MaxWalkSpeed;
|
||||
var maxXSpeed = grounded ? Input.IsActionPressed("run") ? MaxRunSpeed : MaxWalkSpeed : MaxAirSpeed;
|
||||
var maxYSpeed = vely > 0 ? MaxFallSpeed : MaxRiseSpeed;
|
||||
var (absvelx, absvely) = (Mathf.Abs(velx), Mathf.Abs(vely));
|
||||
float xcancel = 0, ycancel = 0;
|
||||
if (absvelx > maxXSpeed) xcancel = -Math.Sign(velx) * CancellationAcceleration * (float)delta;
|
||||
if (absvely > maxYSpeed) ycancel = -Math.Sign(vely) * CancellationAcceleration * (float)delta;
|
||||
if (Mathf.Abs(xcancel) + 0.1 > absvelx) velx = 0;
|
||||
else velx += xcancel;
|
||||
if (Mathf.Abs(ycancel) + 0.1 > absvely) vely = 0;
|
||||
else vely += ycancel;
|
||||
if (absvelx > maxXSpeed)
|
||||
velx = Mathf.Sign(velx) * Mathf.Max(absvelx - CancellationAcceleration * (float)delta, maxXSpeed);
|
||||
if (absvely > maxYSpeed)
|
||||
vely = Mathf.Sign(vely) * Mathf.Max(absvely - CancellationAcceleration * (float)delta, maxYSpeed);
|
||||
|
||||
DebugTextLabel.Text =
|
||||
$"grounded: {grounded}\n" +
|
||||
|
||||
Reference in New Issue
Block a user