Fronter/Mothership.gd

68 lines
1.7 KiB
GDScript

extends Area2D
signal game_over
export (PackedScene) var Laser
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
const STARTING_HEALTH = 500
var health = STARTING_HEALTH
var double_laser = false
var can_shoot = true
var timer = null
var bullet_delay = 0.1
func _ready():
var health_bar = Vector2(((health * (.8)) + 100), 200)
$Line2D.set_point_position( 1, health_bar )
pass
# timer = Timer.new()
# timer.set_one_shot(true)
# timer.set_wait_time(bullet_delay)
# timer.connect("timeout", self, "on_timeout_complete")
# add_child(timer)
func _process(delta):
pass
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass
#func _on_GunAimNode_area_entered(area):
# for i in range(20):
# #var laser = Laser.instance()
# #get_node("../").add_child(laser)
# #laser.position.y = position.y - 27
# #laser.position.x = position.x + 46
# if double_laser == true:
# var laser2 = Laser.instance()
# get_node("../").add_child(laser2)
# laser2.position.y = position.y + 28
# laser2.position.x = position.x + 46
# can_shoot = false
# timer.start()
func _on_Mothership_area_shape_entered(area_id, area, area_shape, self_shape):
health -= 50
prints(health)
var health_bar = Vector2(((health * (.8)) + 100), 200)
$Line2D.set_point_position( 1, health_bar )
if health <= 250:
$AnimatedSprite.frame = 1
if health <= 100:
$AnimatedSprite.frame = 2
if health <= 0:
$AnimatedSprite.frame = 3
emit_signal("game_over")
prints("Game Over!")
func _on_Player_restart_game():
health = STARTING_HEALTH
$AnimatedSprite.frame = 0
var health_bar = Vector2(((health * (.8)) + 100), 200)
$Line2D.set_point_position( 1, health_bar )