8 directional attacks and dashes

This commit is contained in:
Lilith Schier 2026-09-05 15:55:46 +02:00
parent bed5e49547
commit 5b593c9bcc
4 changed files with 50 additions and 5 deletions

View file

@ -34,7 +34,7 @@ project/assembly_name="Dancer"
[editor_plugins]
enabled=PackedStringArray("res://addons/BehaviorDebug/plugin.cfg", "res://addons/TileMapDual/plugin.cfg")
enabled=PackedStringArray("res://addons/BehaviorDebug/plugin.cfg")
[input]

View file

@ -85,11 +85,13 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
[Node] private AnimationTree AnimationTree { get; set; } = null!;
[Node] private Area2D SubmersedSensor { get; set; } = null!;
[Node] private Hitbox DashHitbox { get; set; } = null!;
[Node] private Node2D HandAttachment { get; set; } = null!;
[Node] private Timer JumpTimer { get; set; } = null!;
[Node] private Timer WallJumpTimer { get; set; } = null!;
[Node] private Timer JumpAllowedTimer { get; set; } = null!;
[Node] private Timer WaterJumpAllowedTimer { get; set; } = null!;
[Node] private Timer DashTimer { get; set; } = null!;
[Node] private Timer DashDirectionChangeTimer { get; set; } = null!;
[Node] private Timer DashCooldownTimer { get; set; } = null!;
[Node] private Timer GlobalDamageImmunityTimer { get; set; } = null!;
[Node] private Timer PlatformIgnoreTimer { get; set; } = null!;
@ -161,6 +163,11 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
if (!DashTimer.IsStopped())
{
if (!DashDirectionChangeTimer.IsStopped())
{
DashDirection = _currentDirection;
}
velocity = DashDirection * DashSpeed;
}
// Water movement
@ -464,8 +471,20 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
private void Attack()
{
AdjustFacing();
Velocity += (IsFacingRight ? Vector2.Right : Vector2.Left) * SlashSpeedBoost;
_playback.Travel("front_kick");
// Velocity += (IsFacingRight ? Vector2.Right : Vector2.Left) * SlashSpeedBoost;
// _playback.Travel("front_kick");
// placeholder for directional attacks
var attackPlaceholderScene =
GD.Load<PackedScene>("res://src/player/attack_placeholder.tscn");
var attackPlaceholder = attackPlaceholderScene.Instantiate<Node2D>();
attackPlaceholder.Position = HandAttachment.GlobalPosition - GlobalPosition;
var targetDir = _currentDirection.IsZeroApprox()
? FacingVector
: _currentDirection;
attackPlaceholder.Rotation = Vector2.Up.AngleTo(targetDir);
AddChild(attackPlaceholder);
CreateTween().TweenCallback(Callable.From(attackPlaceholder.QueueFree)).SetDelay(0.2f);
}
private void WaterExitJump()
@ -480,10 +499,16 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
AdjustFacing();
DashPoints -= 1f;
DashTimer.Start();
DashDirectionChangeTimer.Start();
DashCooldownTimer.Start();
CreateTween()
.SetIgnoreTimeScale()
.TweenProperty(Engine.Singleton, "time_scale", 1.0f, 0.15f)
.From(0.01f)
.SetEase(Tween.EaseType.Out);
DashDirection = (_currentDirection.IsZeroApprox()
? FacingVector
: To4DirectionVector(_currentRawDirection)
: _currentDirection
).Normalized();
DashHitbox.StartAttack();
_playback.Travel("side_dash");

View file

@ -0,0 +1,11 @@
[gd_scene format=3 uid="uid://bycdn3lths1qq"]
[node name="AttackPlaceholder" type="Polygon2D" unique_id=2118857772]
color = Color(1, 1, 1, 0.54901963)
offset = Vector2(0, 16)
polygon = PackedVector2Array(-32, -48, 32, -48, 16, -16, -16, -16)
[node name="Area2D" type="Area2D" parent="." unique_id=578891655]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Area2D" unique_id=2127841935]
polygon = PackedVector2Array(-16, 0, -32, -32, 32, -32, 16, 0)

View file

@ -377,6 +377,9 @@ process_callback = 0
limit_enabled = false
editor_draw_screen = false
[node name="AudioListener2D" type="AudioListener2D" parent="." unique_id=1944725412]
current = true
[node name="Body" type="Sprite2D" parent="." unique_id=567060128]
unique_name_in_owner = true
texture = ExtResource("2_mf2ua")
@ -510,7 +513,13 @@ one_shot = true
[node name="DashTimer" type="Timer" parent="." unique_id=18391348]
unique_name_in_owner = true
process_callback = 0
wait_time = 0.15
wait_time = 0.2
one_shot = true
[node name="DashDirectionChangeTimer" type="Timer" parent="." unique_id=911466358]
unique_name_in_owner = true
process_callback = 0
wait_time = 0.05
one_shot = true
[node name="DashCooldownTimer" type="Timer" parent="." unique_id=452015930]