2018-05-23 01:40:45 -04:00
|
|
|
extends Area2D
|
|
|
|
|
|
|
|
signal game_over
|
|
|
|
export (PackedScene) var Laser
|
|
|
|
# class member variables go here, for example:
|
|
|
|
# var a = 2
|
|
|
|
# var b = "textvar"
|
|
|
|
|
2018-05-23 21:35:16 -04:00
|
|
|
const STARTING_HEALTH = 500
|
|
|
|
|
|
|
|
var health = STARTING_HEALTH
|
2018-05-23 01:40:45 -04:00
|
|
|
var double_laser = false
|
|
|
|
var can_shoot = true
|
|
|
|
var timer = null
|
|
|
|
var bullet_delay = 0.1
|
|
|
|
|
|
|
|
func _ready():
|
2018-05-23 21:35:16 -04:00
|
|
|
var health_bar = Vector2(((health * (.8)) + 100), 200)
|
|
|
|
$Line2D.set_point_position( 1, health_bar )
|
2018-05-23 11:02:52 -04:00
|
|
|
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)
|
2018-05-23 01:40:45 -04:00
|
|
|
|
|
|
|
func _process(delta):
|
2018-05-23 21:35:16 -04:00
|
|
|
pass
|
2018-05-23 01:40:45 -04:00
|
|
|
|
|
|
|
# # Called every frame. Delta is time since last frame.
|
|
|
|
# # Update game logic here.
|
|
|
|
# pass
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-05-23 11:02:52 -04:00
|
|
|
#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
|
2018-05-23 21:35:16 -04:00
|
|
|
# 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 )
|