added dash points

This commit is contained in:
Lilith Schier 2026-07-18 13:51:43 +02:00
parent 4f5ae4ac60
commit ca4c73191d
4 changed files with 26 additions and 26 deletions

View file

@ -8,5 +8,5 @@ script="rider-plugin.gd"
[presets] [presets]
active="on" active="off"
presets="presets.json" presets="presets.json"

View file

@ -1,14 +1,17 @@
[runnable_presets]
Linux="Linux"
[preset.0] [preset.0]
name="Linux" name="Linux"
platform="Linux" platform="Linux"
runnable=true
dedicated_server=false dedicated_server=false
custom_features="" custom_features=""
export_filter="all_resources" export_filter="all_resources"
include_filter="" include_filter=""
exclude_filter="" exclude_filter=""
export_path="../../Desktop/export/Dancer.x86_64" export_path="../../Desktop/Exports/Dancer.x86_64"
patches=PackedStringArray() patches=PackedStringArray()
patch_delta_encoding=false patch_delta_encoding=false
patch_delta_compression_level_zstd=19 patch_delta_compression_level_zstd=19
@ -27,7 +30,7 @@ script_export_mode=2
custom_template/debug="" custom_template/debug=""
custom_template/release="" custom_template/release=""
debug/export_console_wrapper=1 debug/export_console_wrapper=1
binary_format/embed_pck=true binary_format/embed_pck=false
texture_format/s3tc_bptc=true texture_format/s3tc_bptc=true
texture_format/etc2_astc=false texture_format/etc2_astc=false
shader_baker/enabled=false shader_baker/enabled=false

View file

@ -34,7 +34,7 @@ project/assembly_name="Dancer"
[editor_plugins] [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] [input]

View file

@ -51,7 +51,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
public float DashSpeed { get; set; } = 400.0f; public float DashSpeed { get; set; } = 400.0f;
[Export(PropertyHint.None, "suffix:s")] [Export(PropertyHint.None, "suffix:s")]
public float DashCooldownDuration { get; set; } = 0.6f; public float DashCooldownDuration { get; set; } = 0.4f;
/// <summary>The angle difference from perfect left/right that still counts.</summary> /// <summary>The angle difference from perfect left/right that still counts.</summary>
[Export(PropertyHint.Range, "0,360,0.1,radians_as_degrees")] [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 DashCooldown { get; } = new();
private Ticker JumpTicker { get; } = new(); private Ticker JumpTicker { get; } = new();
private Vector2 DashDirection { get; set; } private Vector2 DashDirection { get; set; }
private float DashPoints { get; set; }
[Node] private AnimationTree AnimationTree { get; set; } = null!; [Node] private AnimationTree AnimationTree { get; set; } = null!;
[Node] private Area2D SubmersedSensor { 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(); if (CanTurn) AdjustFacing();
// Water movement if (DashTicker.IsRunning)
if (IsInWater)
{ {
if (DashTicker.IsRunning) velocity = DashDirection * DashSpeed;
{ }
velocity = DashDirection * DashSpeed; // Water movement
} else if (IsInWater)
else {
{ velocity += _currentDirection.Normalized() * WaterAccel * deltaF;
velocity += _currentDirection.Normalized() * WaterAccel * deltaF;
}
} }
// Walking on the floor // Walking on the floor
else if (IsOnFloor()) else if (IsOnFloor())
@ -226,6 +224,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
WaterJumpAllowedTicker.Tick(deltaF); WaterJumpAllowedTicker.Tick(deltaF);
DashTicker.Tick(deltaF); DashTicker.Tick(deltaF);
DashCooldown.Tick(deltaF); DashCooldown.Tick(deltaF);
if (IsInWater) DashPoints = Mathf.Min(2, DashPoints + 1f * deltaF);
if (IsOnCeiling()) JumpTicker.Reset(); if (IsOnCeiling()) JumpTicker.Reset();
} }
@ -295,7 +294,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
{ {
if (MatchInput(_inputBuffer[i])) if (MatchInput(_inputBuffer[i]))
{ {
_inputBuffer = _inputBuffer.GetRange(i + 1, _inputBuffer.Count - i - 1); _inputBuffer.RemoveRange(0, i + 1);
break; break;
} }
} }
@ -342,7 +341,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
return true; return true;
case { Action: Action.Dash, IsPressed: true } case { Action: Action.Dash, IsPressed: true }
when (IsInWater && !DashCooldown.IsRunning): when !DashCooldown.IsRunning && DashPoints >= 1f:
Dash(); Dash();
return true; return true;
@ -398,6 +397,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
private void Dash() private void Dash()
{ {
AdjustFacing(); AdjustFacing();
DashPoints -= 1f;
DashTicker.Start(); DashTicker.Start();
DashCooldown.Start(); DashCooldown.Start();
DashDirection = (_currentDirection.IsZeroApprox() DashDirection = (_currentDirection.IsZeroApprox()
@ -409,15 +409,12 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
private static Vector2 To8DirectionVector(Vector2 input) private static Vector2 To8DirectionVector(Vector2 input)
{ {
if (input.IsZeroApprox()) return Vector2.Zero; if (input.IsZeroApprox()) return Vector2.Zero;
const float tan225 = 0.414213562373f; // tan(22.5°)
const float tan225 = 0.4142135623730950488f; // tan(22.5°) = √2 - 1 Vector2 a = input.Abs(), s = input.Sign();
float ax = Mathf.Sign(input.X), ay = Mathf.Abs(input.Y);
float sx = Mathf.Sign(input.X), sy = Mathf.Sign(input.Y);
return return
ay < ax * tan225 ? new(sx, 0) : a.Y < a.X * tan225 ? new(s.X, 0) :
ax < ay * tan225 ? new(0, sy) : a.X < a.Y * tan225 ? new(0, s.Y) :
new(sx, sy); s;
} }
private void OnEnemyHit(Hitbox hitbox, Node2D enemy) private void OnEnemyHit(Hitbox hitbox, Node2D enemy)