30 lines
551 B
C#
30 lines
551 B
C#
using Godot;
|
|
using System;
|
|
|
|
public partial class Laser : Area2D
|
|
{
|
|
[Export]
|
|
public int Speed { get; set;} = 2000;
|
|
|
|
public Vector2 MovementVector { get; set; } = new Vector2(0, -1);
|
|
|
|
|
|
private void _on_visible_on_screen_notifier_2d_screen_exited()
|
|
{
|
|
QueueFree();
|
|
}
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
GlobalPosition += MovementVector.Rotated(Rotation) * Speed * (float)delta;
|
|
}
|
|
private void OnAreaEntered(Area2D area)
|
|
{
|
|
if (area is asteroid)
|
|
{
|
|
asteroid a = (asteroid)area;
|
|
a.Explode();
|
|
QueueFree();
|
|
}
|
|
}
|
|
}
|