80 lines
1.7 KiB
GDScript
80 lines
1.7 KiB
GDScript
extends Node
|
|
|
|
export (PackedScene) var FirstBad
|
|
export (PackedScene) var BlobBad
|
|
export (PackedScene) var UpgradeMenu
|
|
|
|
var position = Vector2(200, 200)
|
|
var total_bads_spawned = 0
|
|
var upgrade_cost = 50
|
|
|
|
func _ready():
|
|
$BaddieTimer.start()
|
|
randomize()
|
|
updatePoints()
|
|
|
|
func _process(delta):
|
|
if (Input.is_action_pressed("ctlr_l")):
|
|
if (Input.is_action_pressed("ctlr_r")):
|
|
if (Input.is_action_pressed("ctlr_a")):
|
|
if (Input.is_action_pressed("ctlr_start")):
|
|
get_tree().quit()
|
|
if (Input.is_action_pressed("ui_quit")):
|
|
get_tree().quit()
|
|
updatePoints()
|
|
|
|
func _on_bad_death(kill_money):
|
|
$Player.money += kill_money
|
|
updatePoints()
|
|
|
|
var sendblob = 0
|
|
func BaddieTimer():
|
|
if total_bads_spawned < 11:
|
|
var bad
|
|
|
|
if sendblob == 5:
|
|
sendblob = 0
|
|
bad = BlobBad.instance()
|
|
else:
|
|
bad = FirstBad.instance()
|
|
sendblob += 1
|
|
|
|
add_child(bad)
|
|
bad.connect("dead", self, "_on_bad_death")
|
|
total_bads_spawned += 1
|
|
$BaddieTimer.wait_time = $BaddieTimer.wait_time * 0.97
|
|
|
|
updatePoints()
|
|
|
|
bad.position.x = 1200
|
|
bad.position.y = (randi()%470) + 40
|
|
else:
|
|
total_bads_spawned = 0
|
|
|
|
func _on_Player_shooting_speed_upgrade():
|
|
updatePoints()
|
|
pass
|
|
|
|
func _on_PauseButton_pressed():
|
|
var upgmenu
|
|
upgmenu = UpgradeMenu.instance()
|
|
add_child(upgmenu)
|
|
upgmenu.connect("refund", self, "_refund_button")
|
|
get_tree().paused = true
|
|
|
|
func updatePoints():
|
|
$MoneyDisplay.text = str($Player.money, " points")
|
|
|
|
#When refund signal from upgrade menu comes in,
|
|
# tell Player to refund upgrades
|
|
func _refund_button():
|
|
$Player.refund()
|
|
|
|
#When refund comes back successfully from Player,
|
|
# pause game again
|
|
func _on_Player_refund(ship_value):
|
|
prints("Refunded for ", ship_value)
|
|
updatePoints()
|
|
get_tree().paused = true
|
|
pass # replace with function body
|