Added combo counter

This commit is contained in:
qwsdcvghyu89
2026-06-18 22:05:44 +10:00
parent 2eaed32b8a
commit a1e0c19ff7
4 changed files with 32 additions and 0 deletions
+10
View File
@@ -20,6 +20,9 @@ public partial class PlayerPhysicsController : CharacterBody2D {
[Signal]
public delegate void OnJumpEventHandler(JumpKind kind, bool isOnGround, bool isOnWall);
[Signal]
public delegate void OnJumpFailEventHandler();
[ExportCategory("Accelerations and Impulses")]
[Export]
@@ -139,6 +142,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
float velx = (Velocity.X / UnitToPx);
float vely = (Velocity.Y / UnitToPx) + Gravity * (float)delta;
var jumped = false;
var grounded = this.IsOnFloor();
var coyoteGrounded = _timeOffGround < CoyoteTiming;
if (grounded || coyoteGrounded) {
@@ -147,6 +151,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
if (Input.IsActionJustPressed("jump")) {
EmitSignal(SignalName.OnJump, (int)JumpKind.Ground, this.IsOnFloor(), this.IsOnWall());
jumped = true;
vely = -_lv;
}
@@ -194,6 +199,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
GD.Print($"Theta: {theta * (180 / Mathf.Pi)}, turnjump: {turnjump}");
velx = turnjump.X;
vely = turnjump.Y;
jumped = true;
} else {
// does not have jump point
// float theta = Mathf.Atan2(-yAxis, Mathf.Abs(xAxis));
@@ -209,6 +215,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
if (Input.IsActionJustPressed("jump") && Mathf.Abs(vely) < MaxDoubleJumpFallSpeed) {
EmitSignal(SignalName.OnJump, (int)JumpKind.Midair, this.IsOnFloor(), this.IsOnWall());
jumped = true;
vely = -_lv;
}
@@ -221,6 +228,9 @@ public partial class PlayerPhysicsController : CharacterBody2D {
else velx += autostop;
}
if (Input.IsActionJustPressed("jump") && !jumped)
EmitSignal(SignalName.OnJumpFail);
var maxXSpeed = grounded ? Input.IsActionPressed("run") ? MaxRunSpeed : MaxWalkSpeed : MaxAirSpeed;
var maxYSpeed = vely > 0 ? MaxFallSpeed : MaxRiseSpeed;
var (absvelx, absvely) = (Mathf.Abs(velx), Mathf.Abs(vely));