cirnogodot/Scripts/Bullet.cs

33 lines
649 B
C#
Raw Normal View History

2024-02-27 17:16:55 +01:00
using Godot;
using System;
using System.Diagnostics;
2024-02-27 22:54:42 +01:00
public partial class Bullet : Area2D
2024-02-27 17:16:55 +01:00
{
2024-02-27 22:54:42 +01:00
[Export]
public float Speed = 1900f;
private Vector2 _direction = Vector2.Right;
2024-02-27 17:16:55 +01:00
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
Debug.WriteLine("Bullet Shot");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
2024-02-27 22:54:42 +01:00
this.Position += ((float) (Speed * delta) * _direction);
}
2024-02-27 17:16:55 +01:00
2024-02-27 22:54:42 +01:00
private void _on_visible_on_screen_notifier_2d_screen_exited()
{
Debug.WriteLine("Destroy bullet out of screen");
QueueFree();
2024-02-27 17:16:55 +01:00
}
2024-02-27 22:54:42 +01:00
2024-02-27 17:16:55 +01:00
}
2024-02-27 22:54:42 +01:00