diff --git a/Assets/y-wing-turret_laser.png b/Assets/y-wing-turret_laser.png new file mode 100644 index 0000000..4eda420 Binary files /dev/null and b/Assets/y-wing-turret_laser.png differ diff --git a/Assets/y-wing-turret_laser.png.import b/Assets/y-wing-turret_laser.png.import new file mode 100644 index 0000000..45d2d72 --- /dev/null +++ b/Assets/y-wing-turret_laser.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ciu3cl3y7luqp" +path="res://.godot/imported/y-wing-turret_laser.png-b082918440eb09c5d26590419698e9b1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/y-wing-turret_laser.png" +dest_files=["res://.godot/imported/y-wing-turret_laser.png-b082918440eb09c5d26590419698e9b1.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Scenes/turret_laser.tscn b/Scenes/turret_laser.tscn new file mode 100644 index 0000000..04c1674 --- /dev/null +++ b/Scenes/turret_laser.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=3 uid="uid://wqrybvg1tf4s"] + +[ext_resource type="Texture2D" uid="uid://ciu3cl3y7luqp" path="res://Assets/y-wing-turret_laser.png" id="1_8xaek"] +[ext_resource type="Script" path="res://Scripts/turret_laser.gd" id="1_17xg5"] + +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_kjs2o"] +radius = 3.0 +height = 64.0 + +[node name="turret_laser" type="Area2D"] +collision_layer = 16 +collision_mask = 3 +script = ExtResource("1_17xg5") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture_filter = 1 +texture = ExtResource("1_8xaek") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0, 2) +shape = SubResource("CapsuleShape2D_kjs2o") diff --git a/Scripts/turret_laser.gd b/Scripts/turret_laser.gd new file mode 100644 index 0000000..e7d3bc1 --- /dev/null +++ b/Scripts/turret_laser.gd @@ -0,0 +1,29 @@ +extends Area2D + +@onready var turret_laser = $Sprite2D + + +var speed = 100 +var target2 : Vector2 +var new_rot +func initialize(firing_solution,target): + print('firing_solution='+str(firing_solution)) + new_rot = firing_solution + #turret_laser.set_rotation(firing_solution) + print(str(turret_laser)) + print(str(firing_solution)) + target2 = target + #print(str(firing_solution)) + +func _ready(): + turret_laser.set_rotation(new_rot) + $CollisionShape2D.set_rotation(new_rot) + +func _physics_process(delta): + #print(str(global_position.x - target.x)) + #print(global_position) + #print(target2) + #print(typeof(global_position)) + #print(typeof(target)) + global_position -= (global_position - target2).normalized() * speed * delta + pass