From ca4c73191d4ae15db495293675424e999a1ade18 Mon Sep 17 00:00:00 2001 From: Lilith Schier Date: Sat, 18 Jul 2026 13:51:43 +0200 Subject: [PATCH] added dash points --- addons/rider-plugin/plugin.cfg | 2 +- export_presets.cfg | 9 +++++--- project.godot | 2 +- src/player/Player.cs | 39 ++++++++++++++++------------------ 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/addons/rider-plugin/plugin.cfg b/addons/rider-plugin/plugin.cfg index 5a4ada1..314ea57 100644 --- a/addons/rider-plugin/plugin.cfg +++ b/addons/rider-plugin/plugin.cfg @@ -8,5 +8,5 @@ script="rider-plugin.gd" [presets] -active="on" +active="off" presets="presets.json" diff --git a/export_presets.cfg b/export_presets.cfg index 61ec3bf..a21e2b8 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -1,14 +1,17 @@ +[runnable_presets] + +Linux="Linux" + [preset.0] name="Linux" platform="Linux" -runnable=true dedicated_server=false custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="../../Desktop/export/Dancer.x86_64" +export_path="../../Desktop/Exports/Dancer.x86_64" patches=PackedStringArray() patch_delta_encoding=false patch_delta_compression_level_zstd=19 @@ -27,7 +30,7 @@ script_export_mode=2 custom_template/debug="" custom_template/release="" debug/export_console_wrapper=1 -binary_format/embed_pck=true +binary_format/embed_pck=false texture_format/s3tc_bptc=true texture_format/etc2_astc=false shader_baker/enabled=false diff --git a/project.godot b/project.godot index daa8747..7b97c69 100644 --- a/project.godot +++ b/project.godot @@ -34,7 +34,7 @@ project/assembly_name="Dancer" [editor_plugins] -enabled=PackedStringArray("res://addons/AsepriteWizard/plugin.cfg", "res://addons/BehaviorDebug/plugin.cfg", "res://addons/TileMapDual/plugin.cfg", "res://addons/rider-plugin/plugin.cfg") +enabled=PackedStringArray("res://addons/AsepriteWizard/plugin.cfg", "res://addons/BehaviorDebug/plugin.cfg", "res://addons/TileMapDual/plugin.cfg") [input] diff --git a/src/player/Player.cs b/src/player/Player.cs index 4776e6c..7493a6f 100644 --- a/src/player/Player.cs +++ b/src/player/Player.cs @@ -51,7 +51,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, public float DashSpeed { get; set; } = 400.0f; [Export(PropertyHint.None, "suffix:s")] - public float DashCooldownDuration { get; set; } = 0.6f; + public float DashCooldownDuration { get; set; } = 0.4f; /// The angle difference from perfect left/right that still counts. [Export(PropertyHint.Range, "0,360,0.1,radians_as_degrees")] @@ -85,6 +85,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, private Ticker DashCooldown { get; } = new(); private Ticker JumpTicker { get; } = new(); private Vector2 DashDirection { get; set; } + private float DashPoints { get; set; } [Node] private AnimationTree AnimationTree { get; set; } = null!; [Node] private Area2D SubmersedSensor { get; set; } = null!; @@ -140,17 +141,14 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, if (CanTurn) AdjustFacing(); - // Water movement - if (IsInWater) + if (DashTicker.IsRunning) { - if (DashTicker.IsRunning) - { - velocity = DashDirection * DashSpeed; - } - else - { - velocity += _currentDirection.Normalized() * WaterAccel * deltaF; - } + velocity = DashDirection * DashSpeed; + } + // Water movement + else if (IsInWater) + { + velocity += _currentDirection.Normalized() * WaterAccel * deltaF; } // Walking on the floor else if (IsOnFloor()) @@ -226,6 +224,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, WaterJumpAllowedTicker.Tick(deltaF); DashTicker.Tick(deltaF); DashCooldown.Tick(deltaF); + if (IsInWater) DashPoints = Mathf.Min(2, DashPoints + 1f * deltaF); if (IsOnCeiling()) JumpTicker.Reset(); } @@ -295,7 +294,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, { if (MatchInput(_inputBuffer[i])) { - _inputBuffer = _inputBuffer.GetRange(i + 1, _inputBuffer.Count - i - 1); + _inputBuffer.RemoveRange(0, i + 1); break; } } @@ -342,7 +341,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, return true; case { Action: Action.Dash, IsPressed: true } - when (IsInWater && !DashCooldown.IsRunning): + when !DashCooldown.IsRunning && DashPoints >= 1f: Dash(); return true; @@ -398,6 +397,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, private void Dash() { AdjustFacing(); + DashPoints -= 1f; DashTicker.Start(); DashCooldown.Start(); DashDirection = (_currentDirection.IsZeroApprox() @@ -409,15 +409,12 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner, private static Vector2 To8DirectionVector(Vector2 input) { if (input.IsZeroApprox()) return Vector2.Zero; - - const float tan225 = 0.4142135623730950488f; // tan(22.5°) = √2 - 1 - float ax = Mathf.Sign(input.X), ay = Mathf.Abs(input.Y); - float sx = Mathf.Sign(input.X), sy = Mathf.Sign(input.Y); - + const float tan225 = 0.414213562373f; // tan(22.5°) + Vector2 a = input.Abs(), s = input.Sign(); return - ay < ax * tan225 ? new(sx, 0) : - ax < ay * tan225 ? new(0, sy) : - new(sx, sy); + a.Y < a.X * tan225 ? new(s.X, 0) : + a.X < a.Y * tan225 ? new(0, s.Y) : + s; } private void OnEnemyHit(Hitbox hitbox, Node2D enemy)