Y wing turret and laser update

This commit is contained in:
zerothelootrat
2024-06-05 17:37:46 -04:00
parent 781ccba218
commit 869ad92e5a
5 changed files with 37 additions and 17 deletions

View File

@@ -16,7 +16,8 @@ currently only have one enemy and one level up type
##todo: ##todo:
- [x] Finish Y-Wing Art - [x] Finish Y-Wing Art
- [ ] Import Y-Wing & get turret working - [x] Import Y-Wing & get turret working
-[x] Implement Y-Wing Main Cannon
- [ ] Power up 2 (shield) - [ ] Power up 2 (shield)
- [ ] locate sounds - [ ] locate sounds
- [ ] World Map - [ ] World Map
@@ -26,3 +27,6 @@ currently only have one enemy and one level up type
update log: update log:
6/4/2024 6/4/2024
First implementation of y-wing sprite, and turret. Scripting to be done later. First implementation of y-wing sprite, and turret. Scripting to be done later.
6/5/2024
Y-Wing implemented, and turret working (X/Y coords for the blaster bolt needs tweaking) Multiple target_pos.x * 2?

View File

@@ -19,3 +19,5 @@ texture = ExtResource("1_8xaek")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 2) position = Vector2(0, 2)
shape = SubResource("CapsuleShape2D_kjs2o") shape = SubResource("CapsuleShape2D_kjs2o")
[connection signal="area_entered" from="." to="." method="_on_area_entered"]

View File

@@ -7,7 +7,7 @@ var missile = preload("res://Scenes/missile.tscn")
var missile_refil = preload("res://Scenes/missile_pickup.tscn") var missile_refil = preload("res://Scenes/missile_pickup.tscn")
var enemy_laser = preload("res://Scenes/enemy_laser.tscn") var enemy_laser = preload("res://Scenes/enemy_laser.tscn")
var enemy_y_wing_turret_laser = null var enemy_y_wing_turret_laser = preload("res://Scenes/turret_laser.tscn")
var enemy_y_wing_main_laser = null var enemy_y_wing_main_laser = null
@onready var player = $player @onready var player = $player
@@ -60,11 +60,13 @@ func fire_enemy_laser(location):
e.global_position = location e.global_position = location
add_child(e) add_child(e)
func firey_wingturret(location,rotation,target): func firey_wingturret(location,firing_solution,target):
print(str(rotation)) var l = enemy_y_wing_turret_laser.instantiate()
print(str(target))
var l = enemy_y_wing_turret_laser.initialize(rotation,target)
l.global_position = location l.global_position = location
l.initialize(firing_solution,target)
#print(str(firing_solution))
add_child(l)
#l.initialize(rotation,target)

View File

@@ -25,8 +25,8 @@ var main_cannon = true
#can turret fire? (rate of fire control) #can turret fire? (rate of fire control)
var turret_cannon = true var turret_cannon = true
var firing_solution = null var firing_solution : float
var target_area = null var target_area : Vector2
#reset raycast, setup settings #reset raycast, setup settings
@@ -52,7 +52,10 @@ func _physics_process(delta):
if target_ray.is_colliding and target_ray.get_collider() is player: if target_ray.is_colliding and target_ray.get_collider() is player:
if turret_cannon == true: if turret_cannon == true:
fire_turret(turret_muzzle,firing_solution,target_area) fire_turret(turret_muzzle.global_position,firing_solution,target_area)
#print(str(turret_muzzle.global_position))
#print(str(firing_solution))
#print(str(target_area))
turret_timer.start() turret_timer.start()
turret_cannon = false turret_cannon = false
@@ -90,8 +93,11 @@ func aim_turret(delta):
firing_solution = atan2(target.y - turret_pos.y, target.x - turret_pos.x)-90*(PI/180) firing_solution = atan2(target.y - turret_pos.y, target.x - turret_pos.x)-90*(PI/180)
target_area = target_pos target_area = target_pos
func fire_turret(location,rotation,target_area): func fire_turret(location,firing_solution,target_area):
get_tree().current_scene.firey_wingturret(location,rotation,target_area) get_tree().current_scene.firey_wingturret(location,firing_solution,target_area)
#print(str(location))
#print(str(firing_solution))
#print(str(target_area))

View File

@@ -3,6 +3,7 @@ extends Area2D
@onready var turret_laser = $Sprite2D @onready var turret_laser = $Sprite2D
var speed = 100 var speed = 100
var target2 : Vector2 var target2 : Vector2
var new_rot var new_rot
@@ -10,14 +11,14 @@ func initialize(firing_solution,target):
print('firing_solution='+str(firing_solution)) print('firing_solution='+str(firing_solution))
new_rot = firing_solution new_rot = firing_solution
#turret_laser.set_rotation(firing_solution) #turret_laser.set_rotation(firing_solution)
print(str(turret_laser)) #print(str(turret_laser))
print(str(firing_solution)) #print(str(firing_solution))
target2 = target target2 = target
#print(str(firing_solution)) #print(str(firing_solution))
func _ready(): func _ready():
turret_laser.set_rotation(new_rot) set_rotation(new_rot)
$CollisionShape2D.set_rotation(new_rot)
func _physics_process(delta): func _physics_process(delta):
#print(str(global_position.x - target.x)) #print(str(global_position.x - target.x))
@@ -26,4 +27,9 @@ func _physics_process(delta):
#print(typeof(global_position)) #print(typeof(global_position))
#print(typeof(target)) #print(typeof(target))
global_position -= (global_position - target2).normalized() * speed * delta global_position -= (global_position - target2).normalized() * speed * delta
pass
func _on_area_entered(area):
if area is player:
area.take_damage(1)
queue_free()