-
Notifications
You must be signed in to change notification settings - Fork 0
/
FireballStraight.cs
52 lines (43 loc) · 1.01 KB
/
FireballStraight.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using Godot;
using System;
using Laugh.code;
public partial class FireballStraight : Area2D
{
[Export] public float FireballSpeed = 400f;
[Export] public float FireballAcceleration = 61.75f;
[Export] public float FireballMaxSpeed = 1000f;
public Vector2 Velocity;
public Vector2 Direction;
public override void _Ready()
{
_getDirectionAndSpeed();
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public override void _PhysicsProcess(double delta)
{
Position += Velocity * (float)delta;
}
private void _getDirectionAndSpeed()
{
GD.Print("direction: " + Direction);
GD.Print("direction: " + this.GlobalPosition);
Velocity = Direction * FireballSpeed;
Rotation = Velocity.Angle();
}
public void OnBodyEntered(Node2D node)
{
GD.Print("node entered ball: " + node.Position);
if (node is Killable k)
{
GD.Print("killable");
k.Kill();
}
}
public void _on_timer_timeout()
{
this.QueueFree();
}
}