Files
SWGalaga/Scenes/world.gd

75 lines
1.7 KiB
GDScript

extends Node2D
#this is a minor change to update the repo.
#asset preloading
var Laser = preload("res://Scenes/PlayerLaser.tscn")
var missile = preload("res://Scenes/missile.tscn")
var missile_refil = preload("res://Scenes/missile_pickup.tscn")
var enemy_laser = preload("res://Scenes/enemy_laser.tscn")
var enemy_y_wing_turret_laser = null
var enemy_y_wing_main_laser = null
@onready var player = $player
#mixed variables for hud
var score = 0
var max_health = 3
var missiles_total = 3
var missiles_current = 3
func _on_player_spawn_laser(location):
var l = Laser.instantiate()
l.global_position = location
add_child(l)
func _on_player_spawn_missile(location):
var m = missile.instantiate()
m.global_position = location
add_child(m)
missiles_current -= 1
$missile_count.text = "Missiles:" + "\n" + str(missiles_current) + "/" + str(missiles_total)
func missile_spawn(location):
#print(str(location.global_position))
var m = missile_refil.instantiate()
m.global_position = location
add_child(m)
func missile_container():
#print("signal recieved")
$player.refil_missiles()
missiles_current = 3
$missile_count.text = "Missiles:" + "\n" + str(missiles_current) + "/" + str(missiles_total)
func player_health(current_health):
var thing = current_health * 100 / max_health
var display = $health
display.text = "Hull Integrity" + "\n" + str(thing) + "%"
func scored():
score += 10
$Score.text = "Score: " + str(score)
func fire_enemy_laser(location):
var e = enemy_laser.instantiate()
e.global_position = location
add_child(e)
func firey_wingturret(location,rotation,target):
print(str(rotation))
print(str(target))
var l = enemy_y_wing_turret_laser.initialize(rotation,target)
l.global_position = location