steering bullets

This commit is contained in:
Maddo 2025-02-27 18:48:13 +01:00
commit 6125565d8c
6 changed files with 89 additions and 67 deletions

View file

@ -35,14 +35,14 @@ public partial class Bullet : Area2D
_gameManager = gameManager;
_elapsedTime = 0f;
// Need to clone them here
// _modifiers = _bulletInfo.TimeModifiers.Select(x => x.MakeClone()).ToList();
// var clonedModifiers = _bulletInfo.TimeModifiers.Select(x => x.MakeClone());
// _modifiers = clonedModifiers.ToList();
// Ugly hack to make instances unique
_modifiers = _bulletInfo.TimeModifiers.Select(x => x.Wrap()).ToList();
}
@ -151,9 +151,26 @@ public partial class Bullet : Area2D
ApplyTimeModifiers(delta);
}
if (BulletInfo.Controllabe)
{
ControlBullet(delta);
}
this.Position += ((float)(Speed * delta) * _direction);
}
private void ControlBullet(double delta)
{
var axis = Input.GetAxis("left", "right");
if (axis != 0)
{
float rotationSpeed = 180f; // Degrees per second
RotateBullet(axis * rotationSpeed * (float)delta);
}
}
private void _on_visible_on_screen_notifier_2d_screen_exited()
{
//Debug.WriteLine("Destroy bullet out of screen");