summaryrefslogtreecommitdiff
path: root/Bullet.cs
diff options
context:
space:
mode:
authoralex <[email protected]>2026-07-24 23:33:46 +0200
committeralex <[email protected]>2026-07-24 23:33:46 +0200
commit91fd5d80808fd177f97c4cc7e78b704efb5d6ce3 (patch)
treefc0dee06eae293afb5e429fa0956455aee585f01 /Bullet.cs
parent6b666c7f25121e61bf1c58ee65cb2cd0f254b887 (diff)
downloadgodot-testing-91fd5d80808fd177f97c4cc7e78b704efb5d6ce3.tar.xz
godot-testing-91fd5d80808fd177f97c4cc7e78b704efb5d6ce3.zip
improved stats resource, weapon now uses dmg from player stats
Diffstat (limited to 'Bullet.cs')
-rw-r--r--Bullet.cs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Bullet.cs b/Bullet.cs
index e613849..4ca9520 100644
--- a/Bullet.cs
+++ b/Bullet.cs
@@ -1,14 +1,17 @@
using Godot;
-
+using testing.interfaces;
public partial class Bullet : Area2D
{
[Export] public float Speed { get; set; } = 600.0f;
+ [Export] public float Damage { get; set; } = 10.0f;
public Vector2 Direction { get; set; } = Vector2.Zero;
public override void _Ready()
{
// Subscribe to the built-in BodyEntered event when the bullet is spawned
BodyEntered += OnBodyEntered;
+
+ Rotation = Direction.Angle();
}
public override void _PhysicsProcess(double delta)
@@ -19,7 +22,10 @@ public partial class Bullet : Area2D
// This method is triggered automatically when the bullet hits a physics body
private void OnBodyEntered(Node2D body)
{
- // QueueFree safely deletes this node and all its children at the end of the current frame
- QueueFree();
+ if (body is IDamageable target)
+ {
+ // If it does, deal damage!
+ target.TakeDamage(Damage);
+ }
}
}