Audio additions: jump.ogg - comitting to continue development in another environment.
Release / Export Game (push) Successful in 2m0s
Release / Export Game (push) Successful in 2m0s
This commit is contained in:
@@ -4,6 +4,12 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
public enum JumpKind {
|
||||
Ground,
|
||||
Turnback,
|
||||
Midair
|
||||
}
|
||||
|
||||
public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
// [Export]
|
||||
// public float RunMultiplier { get; set; } = 1.84f;
|
||||
@@ -11,6 +17,10 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
[Signal]
|
||||
public delegate void OnTurnbackJumpEventHandler(bool onJumpPoint, bool isOnWall);
|
||||
|
||||
[Signal]
|
||||
public delegate void OnJumpEventHandler(JumpKind kind, bool isOnGround, bool isOnWall);
|
||||
|
||||
|
||||
[ExportCategory("Accelerations and Impulses")]
|
||||
[Export]
|
||||
public float WalkAcceleration { get; set; } = 3f;
|
||||
@@ -134,6 +144,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
else _timeOffGround += (float)delta;
|
||||
|
||||
if (Input.IsActionJustPressed("jump")) {
|
||||
EmitSignal(SignalName.OnJump, (int)JumpKind.Ground, this.IsOnFloor(), this.IsOnWall());
|
||||
vely = -_lv;
|
||||
}
|
||||
|
||||
@@ -153,6 +164,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
var side = velx > 0 ? PredictiveCollisions.Location.BottomRight : PredictiveCollisions.Location.BottomLeft;
|
||||
if (Predictor.AnyHit(side) && !this.IsOnWall()) {
|
||||
EmitSignal(SignalName.OnTurnbackJump, true, this.IsOnWall());
|
||||
EmitSignal(SignalName.OnJump, (int)JumpKind.Turnback, this.IsOnFloor(), this.IsOnWall());
|
||||
var hits = Predictor.GetLastCastHits(side);
|
||||
_ = hits.First(x => {
|
||||
if (x.Obj is null) return false;
|
||||
@@ -194,6 +206,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("jump") && Mathf.Abs(vely) < 2) {
|
||||
EmitSignal(SignalName.OnJump, (int)JumpKind.Midair, this.IsOnFloor(), this.IsOnWall());
|
||||
vely = -_lv;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user