diff --git a/sounds/sfx/jump.ogg b/sounds/sfx/jump.ogg new file mode 100644 index 0000000..085c096 Binary files /dev/null and b/sounds/sfx/jump.ogg differ diff --git a/sounds/sfx/jump.ogg.import b/sounds/sfx/jump.ogg.import new file mode 100644 index 0000000..e321b76 --- /dev/null +++ b/sounds/sfx/jump.ogg.import @@ -0,0 +1,19 @@ +[remap] + +importer="oggvorbisstr" +type="AudioStreamOggVorbis" +uid="uid://dkx1v6c7vv0iq" +path="res://.godot/imported/jump.ogg-d217a70c8ca2fe077e37d9f442c771d3.oggvorbisstr" + +[deps] + +source_file="res://sounds/sfx/jump.ogg" +dest_files=["res://.godot/imported/jump.ogg-d217a70c8ca2fe077e37d9f442c771d3.oggvorbisstr"] + +[params] + +loop=false +loop_offset=0 +bpm=0 +beat_count=0 +bar_beats=4 diff --git a/src/components/PlayerPhysicsController.cs b/src/components/PlayerPhysicsController.cs index a5cd2ae..586e722 100644 --- a/src/components/PlayerPhysicsController.cs +++ b/src/components/PlayerPhysicsController.cs @@ -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; } diff --git a/src/components/SfxPlayer.gd b/src/components/SfxPlayer.gd new file mode 100644 index 0000000..6b1a6e2 --- /dev/null +++ b/src/components/SfxPlayer.gd @@ -0,0 +1,2 @@ +extends AudioStreamPlayer + diff --git a/src/components/SfxPlayer.gd.uid b/src/components/SfxPlayer.gd.uid new file mode 100644 index 0000000..6bade70 --- /dev/null +++ b/src/components/SfxPlayer.gd.uid @@ -0,0 +1 @@ +uid://bwgqvwybyrsmq