fixed y-wing turret laser trajectory. - Zerothelootrat

This commit is contained in:
zerothelootrat
2024-06-07 03:35:23 -04:00
parent 62f6b4d873
commit d2dc132952
5 changed files with 64 additions and 19 deletions

View File

@@ -15,18 +15,25 @@ currently only have one enemy and one level up type
##todo:
- [x] Finish Y-Wing Art
- [x] Import Y-Wing & get turret working
-[x] Implement Y-Wing Main Cannon
- [ ] Power up 2 (shield)
- [ ] Power up 2 (shield) : After dinner 6/7/2024
- [ ] locate sounds
- [ ] World Map
- [ ] Work on Boss fight
- [ ] Work on Boss Enemy
- [ ] Spawner Refactor to allow level editing
- [ ] Boss Fight state machine
- [ ] Level 1 and boss fight
##finished:
- [x] Finish Y-Wing Art
- [x] Import Y-Wing & get turret working
- [x] Implement Y-Wing Main Cannon
update log:
6/4/2024
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?
6/7/2024
Y-wing 99% finished, tweaks required. added a few things to objectives list. moved finished objects to finished objects list.

View File

@@ -23,7 +23,7 @@ position = Vector2(370, 0)
position = Vector2(470, 0)
[node name="SpawnTimer" type="Timer" parent="."]
wait_time = 2.0
wait_time = 10.0
autostart = true
[connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"]

View File

@@ -20,4 +20,9 @@ texture = ExtResource("1_8xaek")
position = Vector2(0, 2)
shape = SubResource("CapsuleShape2D_kjs2o")
[node name="Timer" type="Timer" parent="."]
wait_time = 10.0
autostart = true
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

View File

@@ -49,6 +49,7 @@ func _physics_process(delta):
fire_main_cannon()
main_cannon = false
mainCannonFire.start()
aim_turret(delta)
if target_ray.is_colliding and target_ray.get_collider() is player:
@@ -69,19 +70,31 @@ func _physics_process(delta):
#turret.rotate(current_rotation)
#turret.rotation(atan2(target.x - turret_pos.x,target.y - turret_pos.y))
var default_target : Vector2
#figured out with loki, holy shit this was annoying
func aim_turret(delta):
var target : Vector2 = get_tree().current_scene.player.global_position
var turret_pos = turret.global_position
var target_rot = atan2(target.x - turret_pos.x, target.y - turret_pos.y)
var target_pos = get_tree().current_scene.player.global_position
var current_rotation = turret.rotation
var player = get_tree().current_scene.player
if is_instance_valid(player):
var target = get_tree().current_scene.player.global_position
var turret_pos = turret.global_position
var target_rot = atan2(target.x - turret_pos.x, target.y - turret_pos.y)
var target_pos = get_tree().current_scene.player.global_position
var current_rotation = turret.rotation
if target == null:
firing_solution = 0
if target == null:
default_target.x = 0
default_target.y = 0
target = default_target
var speed = 5 #in degrees, can adjust
var direction = 1
if target_rot < current_rotation: #may need to be "<"
direction = -1
var speed = 5 #in degrees, can adjust
var direction = 1
if target_rot < current_rotation: #may need to be "<"
direction = -1
#current_rotation += direction * speed * (PI/180) * delta
#turret.look_at(target_pos)
@@ -90,9 +103,9 @@ func aim_turret(delta):
#current_rotation += current_rotation * 0.90 + target_rot * 0.10
#turret.set_rotation(atan2(target.x - turret_pos.x,target.y - turret_pos.y))
#turret.set_rotation(atan2(turret_pos.x - target.x, turret_pos.y - target_pos.y))
turret.set_rotation(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
turret.set_rotation(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
func fire_turret(location,firing_solution,target_area):
get_tree().current_scene.firey_wingturret(location,firing_solution,target_area)

View File

@@ -7,6 +7,7 @@ extends Area2D
var speed = 100
var target2 : Vector2
var new_rot
var direction
func initialize(firing_solution,target):
print('firing_solution='+str(firing_solution))
new_rot = firing_solution
@@ -18,6 +19,8 @@ func initialize(firing_solution,target):
func _ready():
set_rotation(new_rot)
direction = (target2 - global_position).normalized()
func _physics_process(delta):
@@ -26,10 +29,27 @@ func _physics_process(delta):
#print(target2)
#print(typeof(global_position))
#print(typeof(target))
global_position -= (global_position - target2).normalized() * speed * delta
#var direction = (global_position - target2).normalized()
#print("target2 " + str(target2))
#print("direction normalized " + str(direction))
#print("target_far " + str(target_far))
#print("direction " + str(direction))
#print("target2 " + str(target2))
#global_position += (direction - global_position).normalized() * speed * delta
global_position += direction * speed * delta
if global_position.x >= 980:
#print("cleanup")
queue_free()
func _on_area_entered(area):
if area is player:
area.take_damage(1)
queue_free()
func _on_timer_timeout():
print("cleanup")
queue_free()