Initial repo
This commit is contained in:
66
Scenes/world.gd
Normal file
66
Scenes/world.gd
Normal file
@@ -0,0 +1,66 @@
|
||||
extends Node2D
|
||||
|
||||
#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")
|
||||
@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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user