2018-05-23 01:40:45 -04:00
|
|
|
extends Area2D
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# signals
|
2018-05-23 11:02:52 -04:00
|
|
|
signal update_display # tells parent to update points display
|
|
|
|
signal refund # will tell parent a refund is occuring, for display
|
|
|
|
signal shooting_speed_upgrade # signals that a shooting speed upgrade has occured
|
|
|
|
signal ship_speed_upgrade
|
2018-05-27 02:20:51 -04:00
|
|
|
signal other_shooting_upgrade
|
|
|
|
signal other_ship_speed_upgrade
|
2018-05-23 11:02:52 -04:00
|
|
|
signal shooting_speed_fully_upgraded
|
|
|
|
signal ship_speed_fully_upgraded
|
2018-05-23 21:35:16 -04:00
|
|
|
signal restart_game
|
2018-05-26 04:15:20 -04:00
|
|
|
signal multiplayer_movement
|
2018-05-23 11:02:52 -04:00
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
export (PackedScene) var Laser
|
|
|
|
|
2018-05-26 02:55:17 -04:00
|
|
|
################################
|
2018-05-27 03:46:10 -04:00
|
|
|
# THINGS THAT MAY NEED ADJUSTING
|
2018-05-26 02:55:17 -04:00
|
|
|
#################################
|
2018-05-27 03:46:10 -04:00
|
|
|
|
|
|
|
# first 5 tiers of shooting speed
|
2018-05-23 03:57:15 -04:00
|
|
|
const BULLET_DELAY_TIER1 = 0.8
|
|
|
|
const BULLET_DELAY_TIER2 = 0.5
|
|
|
|
const BULLET_DELAY_TIER3 = 0.2
|
|
|
|
const BULLET_DELAY_TIER4 = 0.1
|
|
|
|
const BULLET_DELAY_TIER5 = 0.05
|
2018-05-27 03:46:10 -04:00
|
|
|
|
|
|
|
# starting cost of shooting speed upgrades after tier 5
|
2018-05-23 11:02:52 -04:00
|
|
|
const SHOOTING_SPEED_UPGRADE_DEFAULT = 1500
|
2018-05-27 03:46:10 -04:00
|
|
|
|
|
|
|
# can't shoot faster than this
|
2018-05-23 11:02:52 -04:00
|
|
|
const BULLET_DELAY_MINIMUM = 0.01
|
2018-05-27 03:46:10 -04:00
|
|
|
|
|
|
|
# costs of shooting speed upgrades
|
2018-05-23 03:57:15 -04:00
|
|
|
const BULLET_DELAY_TIER2_COST = 100
|
|
|
|
const BULLET_DELAY_TIER3_COST = 200
|
|
|
|
const BULLET_DELAY_TIER4_COST = 400
|
|
|
|
const BULLET_DELAY_TIER5_COST = 1000
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# the 5 tiers of ship speed
|
2018-05-23 03:57:15 -04:00
|
|
|
const SHIP_SPEED_TIER1 = 150
|
|
|
|
const SHIP_SPEED_TIER2 = 200
|
|
|
|
const SHIP_SPEED_TIER3 = 300
|
|
|
|
const SHIP_SPEED_TIER4 = 500
|
|
|
|
const SHIP_SPEED_TIER5 = 800
|
2018-05-27 03:46:10 -04:00
|
|
|
|
|
|
|
# costs of ship speed upgrades
|
2018-05-23 11:02:52 -04:00
|
|
|
const SHIP_SPEED_TIER2_COST = 200
|
|
|
|
const SHIP_SPEED_TIER3_COST = 400
|
|
|
|
const SHIP_SPEED_TIER4_COST = 600
|
|
|
|
const SHIP_SPEED_TIER5_COST = 800
|
2018-05-23 03:57:15 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# the ship's starting position
|
|
|
|
const STARTING_POSITION = Vector2(100, 250)
|
|
|
|
|
|
|
|
# the amount of money the player starts with
|
2018-05-24 04:19:59 -04:00
|
|
|
const STARTING_MONEY = 100
|
2018-05-23 21:35:16 -04:00
|
|
|
|
2018-05-26 02:55:17 -04:00
|
|
|
#################################
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# set sliding shooting speed upgrade costs
|
|
|
|
var shooting_speed_upgrade = SHOOTING_SPEED_UPGRADE_DEFAULT
|
|
|
|
|
|
|
|
# used to limit player movement
|
2018-05-23 01:40:45 -04:00
|
|
|
var screensize
|
2018-05-23 03:57:15 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# can the player shoot at this instant
|
|
|
|
var can_shoot = false
|
|
|
|
|
|
|
|
# timer for shooting speed
|
|
|
|
var timer = null
|
|
|
|
|
|
|
|
# sets ship movement speed to the default
|
2018-05-23 03:57:15 -04:00
|
|
|
var ship_speed = SHIP_SPEED_TIER1
|
2018-05-26 02:55:17 -04:00
|
|
|
var ship_speed_tier = 0
|
2018-05-23 03:57:15 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# sets the delay between shots to the default
|
2018-05-23 03:57:15 -04:00
|
|
|
var bullet_delay = BULLET_DELAY_TIER1
|
2018-05-23 21:35:16 -04:00
|
|
|
var bullet_delay_tier = 0
|
2018-05-27 03:46:10 -04:00
|
|
|
|
|
|
|
# sets other shooting settings to their defaults
|
2018-05-23 03:57:15 -04:00
|
|
|
var laser_penetration = 0
|
|
|
|
var double_laser = false
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# gives the player their starting points
|
|
|
|
var money = STARTING_MONEY
|
|
|
|
|
|
|
|
# sets initial value of ship, to be added to with upgrades for refunds
|
2018-05-23 03:57:15 -04:00
|
|
|
var ship_value = 0
|
2018-05-27 03:46:10 -04:00
|
|
|
|
|
|
|
# what percentage of points should be returned on refunding
|
2018-05-23 11:13:48 -04:00
|
|
|
var refund_percentage = 1
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# is a menu open? try to ignore input in-game
|
|
|
|
# only really relevant to touchscreens
|
|
|
|
var menu_open = false
|
2018-05-23 11:02:52 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# opens the upgrade menu
|
2018-05-23 11:02:52 -04:00
|
|
|
func upgradeMenu():
|
2018-05-27 02:20:51 -04:00
|
|
|
menu_open = true
|
2018-05-23 11:02:52 -04:00
|
|
|
var upgmenu = preload("res://UpgradeMenu.tscn").instance()
|
|
|
|
add_child(upgmenu)
|
|
|
|
upgmenu.connect("refund", self, "_refund_button")
|
|
|
|
upgmenu.connect("bullet_delay_upgrade", self, "upgradeBulletDelay_button")
|
2018-05-26 02:55:17 -04:00
|
|
|
upgmenu.connect("ship_speed_upgrade", self, "upgradeShipSpeed_button")
|
2018-05-27 03:46:10 -04:00
|
|
|
upgmenu.connect("double_laser_upgrade", self, "doubleLaserUpgrade_button")
|
|
|
|
upgmenu.connect("laser_penetration_upgrade", self, "laserPenetrationUpgrade_button")
|
2018-05-27 02:20:51 -04:00
|
|
|
upgmenu.connect("menu_closed", self, "menuClosed")
|
2018-05-23 21:35:16 -04:00
|
|
|
upgmenu.bullet_delay_tier = bullet_delay_tier
|
2018-05-26 02:55:17 -04:00
|
|
|
upgmenu.ship_speed_tier = ship_speed_tier
|
2018-05-27 02:20:51 -04:00
|
|
|
if !get_tree().has_network_peer():
|
|
|
|
get_tree().paused = true
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# signalled on close of UpgradeMenu
|
2018-05-27 02:20:51 -04:00
|
|
|
func menuClosed():
|
|
|
|
menu_open = false
|
2018-05-26 02:55:17 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
#######################
|
|
|
|
# REQUESTING UPGRADES #
|
|
|
|
#######################
|
|
|
|
# all will request their upgrade
|
|
|
|
# all will pause the game if not in multiplayer
|
|
|
|
|
|
|
|
func doubleLaserUpgrade_button():
|
|
|
|
doubleLaserUpgrade()
|
|
|
|
emit_signal("update_display")
|
|
|
|
if !get_tree().has_network_peer():
|
|
|
|
get_tree().paused = true
|
|
|
|
|
|
|
|
func laserPenetrationUpgrade_button():
|
|
|
|
laserPenetrationUpgrade()
|
|
|
|
emit_signal("update_display")
|
|
|
|
if !get_tree().has_network_peer():
|
|
|
|
get_tree().paused = true
|
|
|
|
|
2018-05-26 02:55:17 -04:00
|
|
|
func upgradeShipSpeed_button():
|
|
|
|
upgradeShipSpeed()
|
|
|
|
emit_signal("update_display")
|
2018-05-27 02:20:51 -04:00
|
|
|
if !get_tree().has_network_peer():
|
|
|
|
get_tree().paused = true
|
2018-05-23 11:02:52 -04:00
|
|
|
|
|
|
|
func upgradeBulletDelay_button():
|
|
|
|
upgradeBulletDelay()
|
|
|
|
emit_signal("update_display")
|
2018-05-27 02:20:51 -04:00
|
|
|
if !get_tree().has_network_peer():
|
|
|
|
get_tree().paused = true
|
2018-05-23 04:24:00 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
#######################
|
|
|
|
|
|
|
|
|
|
|
|
######################
|
|
|
|
# PROVIDING UPGRADES #
|
|
|
|
######################
|
|
|
|
# checks which tier the player is already on, and if they have enough points
|
|
|
|
# upgrades and charges the player, if possible
|
|
|
|
# increases the ship value by the amount spent, for refunds
|
|
|
|
# sends an rpc message about current state for a given upgrade
|
|
|
|
|
|
|
|
# upgrades shooting speed
|
2018-05-23 04:24:00 -04:00
|
|
|
func upgradeBulletDelay():
|
2018-05-23 11:02:52 -04:00
|
|
|
if (bullet_delay == BULLET_DELAY_TIER1 && money >= BULLET_DELAY_TIER2_COST):
|
|
|
|
bullet_delay = BULLET_DELAY_TIER2
|
|
|
|
money -= BULLET_DELAY_TIER2_COST
|
|
|
|
ship_value += BULLET_DELAY_TIER2_COST
|
2018-05-23 21:35:16 -04:00
|
|
|
bullet_delay_tier = 1
|
2018-05-23 11:02:52 -04:00
|
|
|
elif (bullet_delay == BULLET_DELAY_TIER2 && money >= BULLET_DELAY_TIER3_COST):
|
|
|
|
bullet_delay = BULLET_DELAY_TIER3
|
|
|
|
money -= BULLET_DELAY_TIER3_COST
|
|
|
|
ship_value += BULLET_DELAY_TIER3_COST
|
2018-05-23 21:35:16 -04:00
|
|
|
bullet_delay_tier = 2
|
2018-05-23 11:02:52 -04:00
|
|
|
elif (bullet_delay == BULLET_DELAY_TIER3 && money >= BULLET_DELAY_TIER4_COST):
|
|
|
|
bullet_delay = BULLET_DELAY_TIER4
|
|
|
|
money -= BULLET_DELAY_TIER4_COST
|
|
|
|
ship_value += BULLET_DELAY_TIER4_COST
|
2018-05-23 21:35:16 -04:00
|
|
|
bullet_delay_tier = 3
|
2018-05-23 11:02:52 -04:00
|
|
|
elif (bullet_delay == BULLET_DELAY_TIER4 && money >= BULLET_DELAY_TIER5_COST):
|
|
|
|
bullet_delay = BULLET_DELAY_TIER5
|
|
|
|
money -= BULLET_DELAY_TIER5_COST
|
|
|
|
ship_value += BULLET_DELAY_TIER5_COST
|
2018-05-23 21:35:16 -04:00
|
|
|
bullet_delay_tier = 4
|
2018-05-23 11:02:52 -04:00
|
|
|
elif (bullet_delay <= BULLET_DELAY_MINIMUM):
|
|
|
|
emit_signal("bullet_delay_fully_upgraded")
|
|
|
|
elif (bullet_delay <= BULLET_DELAY_TIER5 && money >= shooting_speed_upgrade):
|
|
|
|
bullet_delay = bullet_delay*0.95
|
|
|
|
money -= shooting_speed_upgrade
|
|
|
|
ship_value += shooting_speed_upgrade
|
|
|
|
shooting_speed_upgrade *= 1.1
|
2018-05-23 21:35:16 -04:00
|
|
|
bullet_delay_tier += 1
|
2018-05-27 02:20:51 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
timer.set_wait_time(bullet_delay)
|
2018-05-27 02:20:51 -04:00
|
|
|
rpc("other_shooting_speed_upgrade", get_tree().get_network_unique_id(), bullet_delay)
|
2018-05-23 11:02:52 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# upgrades the speed at which the ship moves
|
|
|
|
# not relevant for touchscreen users
|
2018-05-23 11:02:52 -04:00
|
|
|
func upgradeShipSpeed():
|
2018-05-26 02:55:17 -04:00
|
|
|
prints("func upgradeShipSpeed():")
|
2018-05-23 11:02:52 -04:00
|
|
|
if (ship_speed == SHIP_SPEED_TIER1 && money >= SHIP_SPEED_TIER2_COST):
|
|
|
|
ship_speed = SHIP_SPEED_TIER2
|
|
|
|
money -= SHIP_SPEED_TIER2_COST
|
|
|
|
ship_value += SHIP_SPEED_TIER2_COST
|
2018-05-26 02:55:17 -04:00
|
|
|
ship_speed_tier = 1
|
2018-05-23 11:02:52 -04:00
|
|
|
elif (ship_speed == SHIP_SPEED_TIER2 && money >= SHIP_SPEED_TIER3_COST):
|
|
|
|
ship_speed = SHIP_SPEED_TIER3
|
|
|
|
money -= SHIP_SPEED_TIER3_COST
|
|
|
|
ship_value += SHIP_SPEED_TIER3_COST
|
2018-05-26 02:55:17 -04:00
|
|
|
ship_speed_tier = 2
|
2018-05-23 11:02:52 -04:00
|
|
|
elif (ship_speed == SHIP_SPEED_TIER3 && money >= SHIP_SPEED_TIER4_COST):
|
|
|
|
ship_speed = SHIP_SPEED_TIER4
|
|
|
|
money -= SHIP_SPEED_TIER4_COST
|
|
|
|
ship_value += SHIP_SPEED_TIER4_COST
|
2018-05-26 02:55:17 -04:00
|
|
|
ship_speed_tier = 3
|
2018-05-23 11:02:52 -04:00
|
|
|
elif (ship_speed == SHIP_SPEED_TIER4 && money >= SHIP_SPEED_TIER5_COST):
|
|
|
|
ship_speed = SHIP_SPEED_TIER5
|
|
|
|
money -= SHIP_SPEED_TIER5_COST
|
|
|
|
ship_value += SHIP_SPEED_TIER5_COST
|
2018-05-26 02:55:17 -04:00
|
|
|
ship_speed_tier = 4
|
2018-05-27 02:20:51 -04:00
|
|
|
|
2018-05-23 11:02:52 -04:00
|
|
|
prints(ship_speed)
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
######################
|
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
func _ready():
|
2018-05-27 03:46:10 -04:00
|
|
|
# for measuring time between lasers
|
2018-05-23 01:40:45 -04:00
|
|
|
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-26 02:55:17 -04:00
|
|
|
timer.start()
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# set player's position to the default
|
|
|
|
position = STARTING_POSITION
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# sets screensize to prevent player leaving screen
|
2018-05-23 01:40:45 -04:00
|
|
|
screensize = get_viewport_rect().size
|
2018-05-27 03:46:10 -04:00
|
|
|
|
|
|
|
# starts the ship's rocketing animation
|
2018-05-23 01:40:45 -04:00
|
|
|
$AnimatedSprite.play()
|
2018-05-23 04:24:00 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# resets all upgrades to the default
|
|
|
|
# refunds them with adjustable percentage returned
|
2018-05-23 11:02:52 -04:00
|
|
|
func _refund_button():
|
2018-05-23 03:57:15 -04:00
|
|
|
bullet_delay = BULLET_DELAY_TIER1
|
2018-05-23 21:35:16 -04:00
|
|
|
bullet_delay_tier = 0
|
2018-05-23 11:02:52 -04:00
|
|
|
timer.set_wait_time(bullet_delay)
|
2018-05-23 03:57:15 -04:00
|
|
|
ship_speed = SHIP_SPEED_TIER1
|
2018-05-27 03:46:10 -04:00
|
|
|
laser_penetration = 0
|
|
|
|
double_laser = false
|
2018-05-23 04:24:00 -04:00
|
|
|
shooting_speed_upgrade = SHOOTING_SPEED_UPGRADE_DEFAULT
|
2018-05-23 03:57:15 -04:00
|
|
|
money += ship_value*refund_percentage
|
2018-05-23 11:02:52 -04:00
|
|
|
prints("Refunded ", ship_value*refund_percentage)
|
2018-05-23 01:40:45 -04:00
|
|
|
ship_value = 0
|
2018-05-23 11:02:52 -04:00
|
|
|
emit_signal("update_display")
|
|
|
|
get_tree().paused = true
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-05-23 03:57:15 -04:00
|
|
|
func on_timeout_complete():
|
|
|
|
can_shoot = true
|
|
|
|
|
2018-05-26 04:15:20 -04:00
|
|
|
var is_shooting
|
|
|
|
|
2018-05-26 02:55:17 -04:00
|
|
|
func moveto(finger_position):
|
2018-05-27 02:20:51 -04:00
|
|
|
if !menu_open:
|
|
|
|
if (finger_position.x > position.x && finger_position.x < 800):
|
|
|
|
velocity.x += 1
|
|
|
|
if position.x > finger_position.x:
|
|
|
|
velocity.x -= 1
|
|
|
|
if (finger_position.y - 100 > position.y && finger_position.x < 800):
|
|
|
|
velocity.y += 1
|
|
|
|
if (position.y > finger_position.y - 100 && finger_position.x < 800):
|
|
|
|
velocity.y -= 1
|
2018-05-26 02:55:17 -04:00
|
|
|
|
2018-05-26 04:15:20 -04:00
|
|
|
remote func move_player(id, position, is_shooting):
|
|
|
|
emit_signal("multiplayer_movement", id, position, is_shooting)
|
2018-05-26 02:55:17 -04:00
|
|
|
|
2018-05-27 02:20:51 -04:00
|
|
|
remote func other_shooting_speed_upgrade(id, bullet_delay):
|
|
|
|
emit_signal("other_shooting_upgrade", id, bullet_delay)
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# the player's movement vector
|
|
|
|
var velocity = Vector2()
|
2018-05-26 02:55:17 -04:00
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
func _process(delta):
|
2018-05-27 03:46:10 -04:00
|
|
|
# move player with keyboard
|
2018-05-26 02:55:17 -04:00
|
|
|
velocity = Vector2()
|
2018-05-27 03:46:10 -04:00
|
|
|
if Input.is_action_pressed("ui_right"):
|
2018-05-23 01:40:45 -04:00
|
|
|
velocity.x += 1
|
2018-05-27 03:46:10 -04:00
|
|
|
if Input.is_action_pressed("ui_left"):
|
2018-05-23 01:40:45 -04:00
|
|
|
velocity.x -= 1
|
2018-05-27 03:46:10 -04:00
|
|
|
if Input.is_action_pressed("ui_down"):
|
2018-05-23 01:40:45 -04:00
|
|
|
velocity.y += 1
|
2018-05-27 03:46:10 -04:00
|
|
|
if Input.is_action_pressed("ui_up"):
|
2018-05-23 01:40:45 -04:00
|
|
|
velocity.y -= 1
|
|
|
|
if (velocity.length() > 0):
|
|
|
|
velocity = velocity.normalized() * ship_speed
|
|
|
|
position += velocity * delta
|
2018-05-27 03:46:10 -04:00
|
|
|
|
|
|
|
# prevents player leaving the screen
|
2018-05-23 01:40:45 -04:00
|
|
|
position.x = clamp(position.x, 0, screensize.x)
|
|
|
|
position.y = clamp(position.y, 0, screensize.y)
|
2018-05-26 04:15:20 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# basically exists just for rpc messages about whether or not the player is currently firing
|
2018-05-26 04:15:20 -04:00
|
|
|
if can_shoot:
|
|
|
|
is_shooting = false
|
|
|
|
else:
|
|
|
|
is_shooting = true
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# if in multiplayer mode, push position and shooting status as often as possible
|
2018-05-26 02:55:17 -04:00
|
|
|
if get_tree().has_network_peer():
|
2018-05-27 02:20:51 -04:00
|
|
|
rpc_unreliable("move_player", get_tree().get_network_unique_id(), position, is_shooting)
|
2018-05-23 04:24:00 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# if shoot button is pressed, try shooting
|
|
|
|
if Input.is_action_pressed("ui_accept"):
|
2018-05-23 03:57:15 -04:00
|
|
|
shoot()
|
2018-05-26 02:55:17 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# ui_reset button opens the upgrade menu
|
|
|
|
if Input.is_action_pressed("ui_reset"):
|
|
|
|
upgradeMenu()
|
2018-05-23 03:57:15 -04:00
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# spawn lasers to shoot
|
|
|
|
# lasers can be set to penetrate or not
|
|
|
|
# can fire two lasers at once if double_laser is on
|
2018-05-23 03:57:15 -04:00
|
|
|
func shoot():
|
2018-05-26 04:15:20 -04:00
|
|
|
if can_shoot:
|
|
|
|
var laser = Laser.instance()
|
|
|
|
get_node("../").add_child(laser)
|
|
|
|
laser.current_pen = laser_penetration
|
|
|
|
laser.position.y = position.y - 27
|
|
|
|
laser.position.x = position.x + 46
|
2018-05-26 02:55:17 -04:00
|
|
|
|
2018-05-26 04:15:20 -04:00
|
|
|
#MAYBE THE LASERS SHOULD BE THEIR OWN NODES
|
|
|
|
#Would allow for more simple additions in the future
|
|
|
|
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
|
|
|
|
laser2.current_pen = laser_penetration
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# don't shoot again until the timer resets
|
2018-05-26 04:15:20 -04:00
|
|
|
can_shoot = false
|
|
|
|
timer.start()
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# displays endgame screen and pauses
|
2018-05-23 21:35:16 -04:00
|
|
|
func gameOver():
|
|
|
|
var gameover = preload("res://GameOver.tscn").instance()
|
|
|
|
add_child(gameover)
|
|
|
|
gameover.connect("restart", self, "restart_game")
|
|
|
|
# gameover.connect("bullet_delay_upgrade", self, "upgradeBulletDelay_button")
|
|
|
|
get_tree().paused = true
|
|
|
|
|
2018-05-27 03:46:10 -04:00
|
|
|
# uses refund function to remove upgrades
|
|
|
|
# sets points back to default
|
2018-05-23 21:35:16 -04:00
|
|
|
func restart_game():
|
|
|
|
_refund_button()
|
|
|
|
get_tree().paused = false
|
|
|
|
money = STARTING_MONEY
|
|
|
|
emit_signal("restart_game")
|