Compare commits
2
Commits
8ad0f3ff65
...
2e152ec36b
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e152ec36b | |||
| a1e0c19ff7 |
@@ -0,0 +1,3 @@
|
|||||||
|
[gd_resource type="Translation" format=3 uid="uid://vs4pl3jum6hp"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
extends Label
|
||||||
|
|
||||||
|
var combo: int = 0;
|
||||||
|
@onready var playerBody: CharacterBody2D = %Player/CharacterBody2D
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
playerBody.connect("OnJump", onJump)
|
||||||
|
playerBody.connect("OnJumpFail", onJumpFail)
|
||||||
|
|
||||||
|
func onJump(kind: int, isOnGround: bool, isOnWall: bool):
|
||||||
|
combo += 1;
|
||||||
|
updateLabel()
|
||||||
|
func onJumpFail():
|
||||||
|
combo = 0;
|
||||||
|
updateLabel()
|
||||||
|
|
||||||
|
func updateLabel():
|
||||||
|
text = "Combo: %d" % combo
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dct1kelhyy04v
|
||||||
@@ -20,6 +20,9 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
[Signal]
|
[Signal]
|
||||||
public delegate void OnJumpEventHandler(JumpKind kind, bool isOnGround, bool isOnWall);
|
public delegate void OnJumpEventHandler(JumpKind kind, bool isOnGround, bool isOnWall);
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void OnJumpFailEventHandler();
|
||||||
|
|
||||||
|
|
||||||
[ExportCategory("Accelerations and Impulses")]
|
[ExportCategory("Accelerations and Impulses")]
|
||||||
[Export]
|
[Export]
|
||||||
@@ -139,6 +142,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
float velx = (Velocity.X / UnitToPx);
|
float velx = (Velocity.X / UnitToPx);
|
||||||
float vely = (Velocity.Y / UnitToPx) + Gravity * (float)delta;
|
float vely = (Velocity.Y / UnitToPx) + Gravity * (float)delta;
|
||||||
|
|
||||||
|
var jumped = false;
|
||||||
var grounded = this.IsOnFloor();
|
var grounded = this.IsOnFloor();
|
||||||
var coyoteGrounded = _timeOffGround < CoyoteTiming;
|
var coyoteGrounded = _timeOffGround < CoyoteTiming;
|
||||||
if (grounded || coyoteGrounded) {
|
if (grounded || coyoteGrounded) {
|
||||||
@@ -147,6 +151,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
|
|
||||||
if (Input.IsActionJustPressed("jump")) {
|
if (Input.IsActionJustPressed("jump")) {
|
||||||
EmitSignal(SignalName.OnJump, (int)JumpKind.Ground, this.IsOnFloor(), this.IsOnWall());
|
EmitSignal(SignalName.OnJump, (int)JumpKind.Ground, this.IsOnFloor(), this.IsOnWall());
|
||||||
|
jumped = true;
|
||||||
vely = -_lv;
|
vely = -_lv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +199,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
GD.Print($"Theta: {theta * (180 / Mathf.Pi)}, turnjump: {turnjump}");
|
GD.Print($"Theta: {theta * (180 / Mathf.Pi)}, turnjump: {turnjump}");
|
||||||
velx = turnjump.X;
|
velx = turnjump.X;
|
||||||
vely = turnjump.Y;
|
vely = turnjump.Y;
|
||||||
|
jumped = true;
|
||||||
} else {
|
} else {
|
||||||
// does not have jump point
|
// does not have jump point
|
||||||
// float theta = Mathf.Atan2(-yAxis, Mathf.Abs(xAxis));
|
// 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) {
|
if (Input.IsActionJustPressed("jump") && Mathf.Abs(vely) < MaxDoubleJumpFallSpeed) {
|
||||||
EmitSignal(SignalName.OnJump, (int)JumpKind.Midair, this.IsOnFloor(), this.IsOnWall());
|
EmitSignal(SignalName.OnJump, (int)JumpKind.Midair, this.IsOnFloor(), this.IsOnWall());
|
||||||
|
jumped = true;
|
||||||
vely = -_lv;
|
vely = -_lv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +228,9 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
else velx += autostop;
|
else velx += autostop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Input.IsActionJustPressed("jump") && !jumped)
|
||||||
|
EmitSignal(SignalName.OnJumpFail);
|
||||||
|
|
||||||
var maxXSpeed = grounded ? Input.IsActionPressed("run") ? MaxRunSpeed : MaxWalkSpeed : MaxAirSpeed;
|
var maxXSpeed = grounded ? Input.IsActionPressed("run") ? MaxRunSpeed : MaxWalkSpeed : MaxAirSpeed;
|
||||||
var maxYSpeed = vely > 0 ? MaxFallSpeed : MaxRiseSpeed;
|
var maxYSpeed = vely > 0 ? MaxFallSpeed : MaxRiseSpeed;
|
||||||
var (absvelx, absvely) = (Mathf.Abs(velx), Mathf.Abs(vely));
|
var (absvelx, absvely) = (Mathf.Abs(velx), Mathf.Abs(vely));
|
||||||
|
|||||||
Reference in New Issue
Block a user