added level restart function
This commit is contained in:
parent
18f5b28295
commit
3247a67e96
12 changed files with 206 additions and 40 deletions
|
@ -1,3 +1,3 @@
|
|||
Game by Penny Rigate
|
||||
Music by Ivy Snyder (https://ivysnyder.newgrounds.com/)
|
||||
Shaders and code help by Hazel Aranda
|
||||
Shaders and code help by Haze
|
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
|
||||
|
|
BIN
graphics/hud/pause_arrow.png
Normal file
BIN
graphics/hud/pause_arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 170 B |
35
graphics/hud/pause_arrow.png.import
Normal file
35
graphics/hud/pause_arrow.png.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/pause_arrow.png-94b6730b4e48cfb550d89f198645b8ee.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://graphics/hud/pause_arrow.png"
|
||||
dest_files=[ "res://.import/pause_arrow.png-94b6730b4e48cfb550d89f198645b8ee.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=12 format=2]
|
||||
[gd_scene load_steps=11 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/theme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://graphics/hud/levelselect_border.png" type="Texture" id=2]
|
||||
[ext_resource path="res://tilesets/t_gui.tres" type="TileSet" id=2]
|
||||
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=3]
|
||||
[ext_resource path="res://graphics/hud/levelselect_arrow.png" type="Texture" id=4]
|
||||
[ext_resource path="res://objects/collectibles/gold.tscn" type="PackedScene" id=5]
|
||||
|
@ -10,29 +10,6 @@
|
|||
[ext_resource path="res://graphics/collectibles/shard.png" type="Texture" id=8]
|
||||
[ext_resource path="res://objects/collectibles/shard.tscn" type="PackedScene" id=9]
|
||||
|
||||
[sub_resource type="TileSet" id=1]
|
||||
0/name = "levelselect_border.png 0"
|
||||
0/texture = ExtResource( 2 )
|
||||
0/tex_offset = Vector2( 0, 0 )
|
||||
0/modulate = Color( 1, 1, 1, 1 )
|
||||
0/region = Rect2( 0, 0, 24, 8 )
|
||||
0/tile_mode = 2
|
||||
0/autotile/icon_coordinate = Vector2( 0, 0 )
|
||||
0/autotile/tile_size = Vector2( 8, 8 )
|
||||
0/autotile/spacing = 0
|
||||
0/autotile/occluder_map = [ ]
|
||||
0/autotile/navpoly_map = [ ]
|
||||
0/autotile/priority_map = [ ]
|
||||
0/autotile/z_index_map = [ ]
|
||||
0/occluder_offset = Vector2( 0, 0 )
|
||||
0/navigation_offset = Vector2( 0, 0 )
|
||||
0/shape_offset = Vector2( 0, 0 )
|
||||
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
0/shape_one_way = false
|
||||
0/shape_one_way_margin = 0.0
|
||||
0/shapes = [ ]
|
||||
0/z_index = 0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=2]
|
||||
shader = ExtResource( 3 )
|
||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||
|
@ -54,7 +31,7 @@ margin_bottom = 144.0
|
|||
color = Color( 0.239216, 0.239216, 0.443137, 1 )
|
||||
|
||||
[node name="Border" type="TileMap" parent="."]
|
||||
tile_set = SubResource( 1 )
|
||||
tile_set = ExtResource( 2 )
|
||||
cell_size = Vector2( 8, 8 )
|
||||
format = 1
|
||||
tile_data = PoolIntArray( 327685, 0, 0, 327686, 536870912, 1, 327687, 0, 1, 327688, 0, 1, 327689, 0, 1, 327690, 0, 1, 327691, 0, 1, 327692, 0, 1, 327693, 0, 1, 327694, 0, 1, 327695, 0, 1, 327696, 0, 1, 327697, 0, 1, 327698, 0, 1, 327699, 0, 1, 327700, 0, 1, 327701, 0, 1, 327702, 0, 1, 327703, 0, 1, 327704, 0, 1, 327705, 0, 1, 327706, 536870912, 0, 393221, 1073741824, 2, 393242, 1610612736, 2, 458757, 1073741824, 2, 458778, 1610612736, 2, 524293, 1073741824, 2, 524314, 1610612736, 2, 589829, 1073741824, 2, 589850, 1610612736, 2, 655365, 1073741824, 2, 655386, 1610612736, 2, 720901, 1073741824, 2, 720922, 1610612736, 2, 786437, 1073741824, 2, 786458, 1610612736, 2, 851973, 1073741824, 2, 851994, 1610612736, 2, 917509, 1073741824, 2, 917530, 1610612736, 2, 983045, 1073741824, 2, 983066, 1610612736, 2, 1048581, 1073741824, 2, 1048602, 1610612736, 2, 1114117, 1073741824, 2, 1114138, 1610612736, 2, 1179653, 1073741824, 0, 1179654, 1073741824, 1, 1179655, 1610612736, 1, 1179656, 1610612736, 1, 1179657, 1610612736, 1, 1179658, 1610612736, 1, 1179659, 1610612736, 1, 1179660, 1610612736, 1, 1179661, 1610612736, 1, 1179662, 1610612736, 1, 1179663, 1610612736, 1, 1179664, 1610612736, 1, 1179665, 1610612736, 1, 1179666, 1610612736, 1, 1179667, 1610612736, 1, 1179668, 1610612736, 1, 1179669, 1610612736, 1, 1179670, 1610612736, 1, 1179671, 1610612736, 1, 1179672, 1610612736, 1, 1179673, 1073741824, 1, 1179674, 1610612736, 0 )
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=13 format=2]
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://objects/player/player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://tilesets/t_cave.tres" type="TileSet" id=2]
|
||||
|
@ -12,6 +12,7 @@
|
|||
[ext_resource path="res://objects/enemy/slime.tscn" type="PackedScene" id=10]
|
||||
[ext_resource path="res://maps/map.gd" type="Script" id=11]
|
||||
[ext_resource path="res://audio/music/smokestack.mp3" type="AudioStream" id=12]
|
||||
[ext_resource path="res://objects/collectibles/arrow.tscn" type="PackedScene" id=13]
|
||||
|
||||
[node name="Map" type="Node2D" groups=["map"]]
|
||||
script = ExtResource( 11 )
|
||||
|
@ -43,8 +44,11 @@ tile_data = PoolIntArray( 196618, 0, 65537, 196619, 0, 65537, 196620, 0, 65537,
|
|||
[node name="Slime" parent="." instance=ExtResource( 10 )]
|
||||
position = Vector2( 84, -7 )
|
||||
|
||||
[node name="Arrow" parent="." instance=ExtResource( 13 )]
|
||||
position = Vector2( 77, 164 )
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 84, 14 )
|
||||
position = Vector2( 64, 162 )
|
||||
|
||||
[node name="Ladder2" parent="." instance=ExtResource( 9 )]
|
||||
position = Vector2( 56, 104 )
|
||||
|
|
21
objects/hud/pause_screen.gd
Normal file
21
objects/hud/pause_screen.gd
Normal 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
|
89
objects/hud/pause_screen.tscn
Normal file
89
objects/hud/pause_screen.tscn
Normal 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"]
|
|
@ -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):
|
||||
|
|
|
@ -123,6 +123,11 @@ debug_testroom={
|
|||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":89,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
pause={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
|
|
@ -40,8 +40,7 @@ func _physics_process(delta):
|
|||
console.visible = !console.visible
|
||||
#Restart scene
|
||||
if Input.is_action_just_pressed("debug_restart"):
|
||||
Game.lives = -1
|
||||
Game.get_map().get_node("Player").die()
|
||||
Game.restart_level()
|
||||
#Move player to mouse
|
||||
if Input.is_action_pressed("debug_move_player"):
|
||||
Game.get_map().get_node("Player").position = get_viewport().get_mouse_position()
|
||||
|
|
26
tilesets/t_gui.tres
Normal file
26
tilesets/t_gui.tres
Normal file
|
@ -0,0 +1,26 @@
|
|||
[gd_resource type="TileSet" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://graphics/hud/levelselect_border.png" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
0/name = "levelselect_border.png 0"
|
||||
0/texture = ExtResource( 1 )
|
||||
0/tex_offset = Vector2( 0, 0 )
|
||||
0/modulate = Color( 1, 1, 1, 1 )
|
||||
0/region = Rect2( 0, 0, 24, 8 )
|
||||
0/tile_mode = 2
|
||||
0/autotile/icon_coordinate = Vector2( 0, 0 )
|
||||
0/autotile/tile_size = Vector2( 8, 8 )
|
||||
0/autotile/spacing = 0
|
||||
0/autotile/occluder_map = [ ]
|
||||
0/autotile/navpoly_map = [ ]
|
||||
0/autotile/priority_map = [ ]
|
||||
0/autotile/z_index_map = [ ]
|
||||
0/occluder_offset = Vector2( 0, 0 )
|
||||
0/navigation_offset = Vector2( 0, 0 )
|
||||
0/shape_offset = Vector2( 0, 0 )
|
||||
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
0/shape_one_way = false
|
||||
0/shape_one_way_margin = 0.0
|
||||
0/shapes = [ ]
|
||||
0/z_index = 0
|
Loading…
Add table
Add a link
Reference in a new issue