Fronter/Main.gd

78 lines
1.7 KiB
GDScript

extends Node
export (PackedScene) var FirstBad
export (PackedScene) var BlobBad
var position = Vector2(200, 200)
var total_bads_spawned = 0
var upgrade_cost = 50
const BADDIE_WAIT_TIME_DEFAULT = 5
func _ready():
var mainmenu = preload("res://MainMenu.tscn").instance()
add_child(mainmenu)
get_tree().paused = true
$BaddieTimer.wait_time = BADDIE_WAIT_TIME_DEFAULT
$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_PauseButton_pressed():
$Player.upgradeMenu()
func updatePoints():
$MoneyDisplay.text = str($Player.money, " points")
func _on_Player_update_display():
updatePoints()
func _on_Mothership_game_over():
$Player.gameOver()
func _on_Player_restart_game():
for child in self.get_children():
if (child.has_method("_on_Visibility_screen_exited")):
child.queue_free()
total_bads_spawned = 0
$BaddieTimer.wait_time = BADDIE_WAIT_TIME_DEFAULT