feat: turrents and explosions
This commit is contained in:
@@ -4,10 +4,25 @@ namespace GodotHostTest.Game.Projectile;
|
||||
|
||||
public partial class Projectile : Node2D
|
||||
{
|
||||
[Export] private PackedScene _explosionPackedScene = null!;
|
||||
[Export] private float _speed = 100;
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
Position += (float)delta * _speed * Vector2.Up.Rotated(Rotation);
|
||||
}
|
||||
|
||||
private void OnArea2DEntered(Area2D _)
|
||||
{
|
||||
var explosion = (GpuParticles2D)_explosionPackedScene.Instantiate();
|
||||
explosion.GlobalPosition = GlobalPosition;
|
||||
explosion.Emitting = true;
|
||||
GetTree().CurrentScene.AddChild(explosion);
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
private void OnScreenExited()
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user