added level restart function
This commit is contained in:
parent
18f5b28295
commit
3247a67e96
12 changed files with 206 additions and 40 deletions
18
game.gd
18
game.gd
|
@ -36,6 +36,7 @@ onready var a_shoot = preload("res://audio/sounds/a_egg_shoot.ogg")
|
|||
onready var a_die = preload("res://audio/sounds/die.wav")
|
||||
#Objects
|
||||
onready var block_text = preload("res://objects/hud/blocktext.tscn")
|
||||
const pause_screen = preload("res://objects/hud/pause_screen.tscn")
|
||||
var respawn_point = Vector2(32,166) #Respawn point
|
||||
var current_level = 0 #Current level being played
|
||||
var current_file = 1 #Current save file
|
||||
|
@ -97,6 +98,7 @@ func save():
|
|||
if Game.shards_collected[9] == true: save.set_value(str(current_level),"Shard9",Game.shards_collected[9])
|
||||
save.save(str("user://file") + str(current_file) + str(".pr"))
|
||||
|
||||
#Convert seconds into M:SS:MS
|
||||
func timeify(input):
|
||||
var minutes = str(floor(input / 60))
|
||||
var seconds = floor(fmod(input,60))
|
||||
|
@ -106,6 +108,18 @@ func timeify(input):
|
|||
else:
|
||||
return "9:59:99"
|
||||
|
||||
#Restart level
|
||||
func restart_level():
|
||||
if Game.score > Game.high_score: Game.high_score = Game.score
|
||||
Game.score = 0
|
||||
Game.golds = 0
|
||||
Game.stars = [false,false,false,false,false]
|
||||
Game.shards = 0
|
||||
Game.arrows = 0
|
||||
Game.lives = 2
|
||||
Game.ac_climb.stop()
|
||||
Game.change_map(load(Game.get_map().filename))
|
||||
|
||||
func _process(delta):
|
||||
if Debug.entry == false:
|
||||
#CRT FILTER
|
||||
|
@ -118,3 +132,7 @@ func _process(delta):
|
|||
OS.set_window_fullscreen(true)
|
||||
else:
|
||||
OS.set_window_fullscreen(false)
|
||||
#Pause
|
||||
if Input.is_action_just_pressed("pause"):
|
||||
instance_node(pause_screen,0,0,get_parent())
|
||||
get_tree().paused = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue