diff --git a/MB_FYP/scenes/laser.tscn b/MB_FYP/scenes/laser.tscn index 526c240..7e60e1f 100644 --- a/MB_FYP/scenes/laser.tscn +++ b/MB_FYP/scenes/laser.tscn @@ -12,15 +12,12 @@ scale = Vector2(0.6, 0.6) script = ExtResource("1_ctmji") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2(0, -27) shape = SubResource("CapsuleShape2D_odhrn") [node name="Sprite2D" type="Sprite2D" parent="."] -position = Vector2(0, -28) texture = ExtResource("2_nq6d6") [node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."] -position = Vector2(0, -27.5) scale = Vector2(0.5, 2.75) [connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"] diff --git a/MB_FYP/script/game.cs b/MB_FYP/script/game.cs index 1313f57..b04dd67 100644 --- a/MB_FYP/script/game.cs +++ b/MB_FYP/script/game.cs @@ -5,23 +5,31 @@ public partial class game : Node2D { public Node Lasers = null; public CharacterBody2D Player = null; - public Area2D Laser = null; + //public Area2D Laser = null; public override void _Ready() { - //Lasers = GetNode("Lasers"); - //Player = GetNode("Player"); + Lasers = GetNode("Lasers"); + Player = GetNode("Player"); //Laser = GetNode("Laser"); //Callable OnLaserShot = new Callable(this, "_on_player_laser_shot"); - //Player.Connect("LaserShot", OnLaserShot); + //Player.Connect("LaserShot", ); + var p = new player(); + //var l = new Laser(); + p.LaserShot += _on_player_laser_shot; + + - //Player.ShootLaser += () => _on_player_laser_shot(Laser); + + } public void _on_player_laser_shot(Area2D Laser) { Lasers.AddChild(Laser); + GD.Print(Laser.Position); + GD.Print(Player.Position); } diff --git a/MB_FYP/script/player.cs b/MB_FYP/script/player.cs index 39b05ec..43114a0 100644 --- a/MB_FYP/script/player.cs +++ b/MB_FYP/script/player.cs @@ -12,7 +12,7 @@ public partial class player : CharacterBody2D [Export] public int MainSpeed { get; set; } = 10; [Export] - public int StrafeSpeed { get; set; } = 4; + public int StrafeSpeed { get; set; } = 5; [Export] public float RotationSpeed { get; set; } = 2f; @@ -43,12 +43,17 @@ public partial class player : CharacterBody2D public void ShootLaser() { Node2D Laser = LaserScene.Instantiate(); - Laser.Position = LaserSpawn.Position; + Laser.Position = LaserSpawn.GlobalPosition; Laser.Rotation = Rotation; GD.Print("shoooot"); + var l = new Laser + { + Position = new Vector2(LaserSpawn.Position.X, LaserSpawn.Position.Y), + Rotation = Rotation + }; EmitSignal(SignalName.LaserShot, Laser); //GetParent().AddChild(Laser); - AddChild(Laser); + //AddChild(Laser); } public override void _Ready()