added level restart function

This commit is contained in:
pennyrigate 2023-01-16 03:19:06 -05:00
parent 18f5b28295
commit 3247a67e96
12 changed files with 206 additions and 40 deletions

View file

@ -0,0 +1,21 @@
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
get_tree().paused = true
$Body/Resume.grab_focus()
func _on_Resume_pressed():
get_tree().paused = false
queue_free()
func _on_Restart_pressed():
Game

View file

@ -0,0 +1,89 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://tilesets/t_gui.tres" type="TileSet" id=1]
[ext_resource path="res://scripts/theme.tres" type="Theme" id=2]
[ext_resource path="res://graphics/hud/pause_arrow.png" type="Texture" id=3]
[ext_resource path="res://objects/hud/pause_screen.gd" type="Script" id=4]
[node name="PauseScreen" type="Node2D"]
pause_mode = 2
script = ExtResource( 4 )
[node name="TileMap" type="TileMap" parent="."]
pause_mode = 2
tile_set = ExtResource( 1 )
cell_size = Vector2( 8, 8 )
format = 1
tile_data = PoolIntArray( 524296, 0, 0, 524297, 536870912, 1, 524298, 536870912, 1, 524299, 536870912, 1, 524300, 536870912, 1, 524301, 536870912, 1, 524302, 536870912, 1, 524303, 536870912, 1, 524304, 536870912, 1, 524305, 536870912, 1, 524306, 536870912, 1, 524307, 536870912, 1, 524308, 536870912, 1, 524309, 536870912, 1, 524310, 536870912, 1, 524311, 536870912, 0, 589832, 0, 2, 589847, 536870912, 2, 655368, 0, 2, 655383, 536870912, 2, 720904, 0, 2, 720919, 536870912, 2, 786440, 0, 2, 786455, 536870912, 2, 851976, 0, 2, 851991, 536870912, 2, 917512, 0, 2, 917527, 536870912, 2, 983048, 1073741824, 0, 983049, 1610612736, 1, 983050, 1610612736, 1, 983051, 1610612736, 1, 983052, 1610612736, 1, 983053, 1610612736, 1, 983054, 1610612736, 1, 983055, 1610612736, 1, 983056, 1610612736, 1, 983057, 1610612736, 1, 983058, 1610612736, 1, 983059, 1610612736, 1, 983060, 1610612736, 1, 983061, 1610612736, 1, 983062, 1610612736, 1, 983063, 1610612736, 0 )
[node name="ColorRect" type="ColorRect" parent="."]
pause_mode = 2
margin_left = 67.0
margin_top = 72.0
margin_right = 189.0
margin_bottom = 120.0
color = Color( 0.239216, 0.239216, 0.443137, 1 )
[node name="Paused" type="Label" parent="."]
pause_mode = 2
margin_left = 64.0
margin_top = 56.0
margin_right = 192.0
margin_bottom = 70.0
theme = ExtResource( 2 )
text = "PAUSED!"
align = 1
[node name="Body" type="Label" parent="."]
pause_mode = 2
margin_left = 64.0
margin_top = 74.0
margin_right = 192.0
margin_bottom = 122.0
theme = ExtResource( 2 )
text = "RESUME
RESTART
SETTINGS
EXit level"
align = 1
[node name="Resume" type="TextureButton" parent="Body"]
pause_mode = 2
margin_left = 36.0
margin_top = 3.0
margin_right = 44.0
margin_bottom = 11.0
focus_neighbour_bottom = NodePath("../Restart")
texture_focused = ExtResource( 3 )
[node name="Restart" type="TextureButton" parent="Body"]
pause_mode = 2
margin_left = 32.0
margin_top = 13.0
margin_right = 40.0
margin_bottom = 21.0
focus_neighbour_top = NodePath("../Resume")
focus_neighbour_bottom = NodePath("../Settings")
texture_focused = ExtResource( 3 )
[node name="Settings" type="TextureButton" parent="Body"]
pause_mode = 2
margin_left = 29.0
margin_top = 23.0
margin_right = 37.0
margin_bottom = 31.0
focus_neighbour_top = NodePath("../Restart")
focus_neighbour_bottom = NodePath("../ExitLevel")
texture_focused = ExtResource( 3 )
[node name="ExitLevel" type="TextureButton" parent="Body"]
pause_mode = 2
margin_left = 22.0
margin_top = 33.0
margin_right = 30.0
margin_bottom = 41.0
focus_neighbour_top = NodePath("../Settings")
texture_focused = ExtResource( 3 )
[connection signal="pressed" from="Body/Resume" to="." method="_on_Resume_pressed"]
[connection signal="pressed" from="Body/Restart" to="." method="_on_Restart_pressed"]

View file

@ -253,15 +253,7 @@ func die():
Game.lives -= 1
Game.play_sound(Game.a_die,Game.ac_die)
if Game.lives < 0:
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(get_owner().filename))
Game.restart_level()
func _on_AnimationPlayer_animation_finished(anim_name):