Add pause menu functionality and update collectable nodes with collision shapes
This commit is contained in:
@@ -11,8 +11,10 @@ export_files=PackedStringArray("res://scenes/test.tscn", "res://objects/brick_pl
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="builds/optimized_for_size/Mr. Brick Adventures.exe"
|
||||
patches=PackedStringArray()
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
seed=0
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
script_export_mode=2
|
||||
@@ -76,8 +78,10 @@ export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="builds/index.html"
|
||||
patches=PackedStringArray()
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
seed=0
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
script_export_mode=2
|
||||
@@ -105,3 +109,45 @@ progressive_web_app/icon_144x144=""
|
||||
progressive_web_app/icon_180x180=""
|
||||
progressive_web_app/icon_512x512=""
|
||||
progressive_web_app/background_color=Color(0, 0, 0, 1)
|
||||
|
||||
[preset.2]
|
||||
|
||||
name="Linux"
|
||||
platform="Linux"
|
||||
runnable=true
|
||||
advanced_options=false
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="builds/linux/ppc.x86_64"
|
||||
patches=PackedStringArray()
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
seed=0
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
script_export_mode=2
|
||||
|
||||
[preset.2.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
debug/export_console_wrapper=1
|
||||
binary_format/embed_pck=false
|
||||
texture_format/s3tc_bptc=true
|
||||
texture_format/etc2_astc=false
|
||||
binary_format/architecture="x86_64"
|
||||
ssh_remote_deploy/enabled=false
|
||||
ssh_remote_deploy/host="user@host_ip"
|
||||
ssh_remote_deploy/port="22"
|
||||
ssh_remote_deploy/extra_args_ssh=""
|
||||
ssh_remote_deploy/extra_args_scp=""
|
||||
ssh_remote_deploy/run_script="#!/usr/bin/env bash
|
||||
export DISPLAY=:0
|
||||
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
|
||||
\"{temp_dir}/{exe_name}\" {cmd_args}"
|
||||
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
|
||||
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
|
||||
rm -rf \"{temp_dir}\""
|
||||
|
@@ -23,9 +23,10 @@ hframes = 12
|
||||
vframes = 12
|
||||
frame = 51
|
||||
|
||||
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "sfx") groups=["coins"]]
|
||||
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "collision_shape", "sfx") groups=["coins"]]
|
||||
script = ExtResource("2_7cph7")
|
||||
area2d = NodePath("..")
|
||||
collision_shape = NodePath("../CollisionShape2D")
|
||||
collectable_data = ExtResource("3_lk3av")
|
||||
sfx = NodePath("../sfx")
|
||||
|
||||
|
@@ -22,9 +22,10 @@ hframes = 12
|
||||
vframes = 12
|
||||
frame = 64
|
||||
|
||||
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "sfx") groups=["coins"]]
|
||||
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "collision_shape", "sfx") groups=["coins"]]
|
||||
script = ExtResource("2_cujcq")
|
||||
area2d = NodePath("..")
|
||||
collision_shape = NodePath("../CollisionShape2D")
|
||||
collectable_data = ExtResource("3_k64cr")
|
||||
sfx = NodePath("../sfx")
|
||||
|
||||
|
@@ -22,9 +22,10 @@ hframes = 12
|
||||
vframes = 12
|
||||
frame = 51
|
||||
|
||||
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "sfx") groups=["coins"]]
|
||||
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "collision_shape", "sfx") groups=["coins"]]
|
||||
script = ExtResource("2_y0k47")
|
||||
area2d = NodePath("..")
|
||||
collision_shape = NodePath("../CollisionShape2D")
|
||||
collectable_data = ExtResource("3_fm2fq")
|
||||
sfx = NodePath("../sfx")
|
||||
|
||||
|
81
objects/pause_menu.tscn
Normal file
81
objects/pause_menu.tscn
Normal file
@@ -0,0 +1,81 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://i6mnjbjcoqe5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cugifchx6jhuk" path="res://scripts/pause_menu.gd" id="1_aktha"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_g4ivv"]
|
||||
bg_color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="Pause menu" type="Control" node_paths=PackedStringArray("pause_menu_control", "resume_button", "quit_button", "settings_button", "exit_to_menu_button")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 6
|
||||
size_flags_vertical = 6
|
||||
script = ExtResource("1_aktha")
|
||||
pause_menu_control = NodePath(".")
|
||||
resume_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/Resume Button")
|
||||
quit_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/Quit game Button")
|
||||
settings_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/Settings Button")
|
||||
exit_to_menu_button = NodePath("PanelContainer/MarginContainer/VBoxContainer/Exit to menu Button")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -209.0
|
||||
offset_top = -128.0
|
||||
offset_right = 209.0
|
||||
offset_bottom = 128.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_g4ivv")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 8
|
||||
theme_override_constants/margin_top = 8
|
||||
theme_override_constants/margin_right = 8
|
||||
theme_override_constants/margin_bottom = 8
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="Pause" type="Label" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Pause"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
uppercase = true
|
||||
|
||||
[node name="Spacer" type="Control" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(0, 32)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Resume Button" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "RESUME"
|
||||
flat = true
|
||||
|
||||
[node name="Settings Button" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "SETTINGS"
|
||||
flat = true
|
||||
|
||||
[node name="Exit to menu Button" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "EXIT TO MENU"
|
||||
flat = true
|
||||
|
||||
[node name="Quit game Button" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "QUIT GAME"
|
||||
flat = true
|
@@ -22,9 +22,10 @@ hframes = 12
|
||||
vframes = 12
|
||||
frame = 66
|
||||
|
||||
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "sfx") groups=["coins"]]
|
||||
[node name="Collectable" type="Node" parent="." node_paths=PackedStringArray("area2d", "collision_shape", "sfx") groups=["coins"]]
|
||||
script = ExtResource("2_i1ssp")
|
||||
area2d = NodePath("..")
|
||||
collision_shape = NodePath("../CollisionShape2D")
|
||||
collectable_data = ExtResource("3_uknsr")
|
||||
sfx = NodePath("../sfx")
|
||||
|
||||
|
@@ -136,6 +136,13 @@ show_marketplace={
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
pause={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":80,"key_label":0,"unicode":112,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=38 format=4 uid="uid://h60obxmju6mo"]
|
||||
[gd_scene load_steps=39 format=4 uid="uid://h60obxmju6mo"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://djifxc5x0dyrw" path="res://sprites/ppc_tileset.png" id="1_5lb42"]
|
||||
[ext_resource type="TileSet" uid="uid://cl4bn8lofqvky" path="res://tileset/village/tileset_village.tres" id="1_d680t"]
|
||||
@@ -26,6 +26,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://dlm2ri562fynd" path="res://objects/marketplace.tscn" id="20_ss8k0"]
|
||||
[ext_resource type="PackedScene" uid="uid://d0s2abysa86rq" path="res://objects/child.tscn" id="21_8rhdx"]
|
||||
[ext_resource type="PackedScene" uid="uid://b4pdt1gv2ymyi" path="res://objects/tooltip.tscn" id="25_ckf05"]
|
||||
[ext_resource type="PackedScene" uid="uid://i6mnjbjcoqe5" path="res://objects/pause_menu.tscn" id="25_j7bvy"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_cagp7"]
|
||||
texture = ExtResource("1_5lb42")
|
||||
@@ -512,6 +513,7 @@ tile_set = SubResource("TileSet_vdmvp")
|
||||
collision_enabled = false
|
||||
|
||||
[node name="Enemies" type="Node2D" parent="."]
|
||||
process_mode = 1
|
||||
|
||||
[node name="Enemy3" parent="Enemies" instance=ExtResource("7_qgddg")]
|
||||
position = Vector2(1433, -224)
|
||||
@@ -561,6 +563,7 @@ follow_mode = 1
|
||||
follow_target = NodePath("../Brick Player")
|
||||
tween_resource = SubResource("Resource_lsjk3")
|
||||
follow_damping = true
|
||||
draw_limits = true
|
||||
limit_target = NodePath("../Terrain Layer")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
@@ -579,6 +582,8 @@ root = NodePath(".")
|
||||
skill_unlocker = NodePath("../../Brick Player/SkillUnlockerComponent")
|
||||
components_to_disable = [NodePath("../../Brick Player")]
|
||||
|
||||
[node name="Pause menu" parent="CanvasLayer" instance=ExtResource("25_j7bvy")]
|
||||
|
||||
[node name="Killzone" parent="." instance=ExtResource("20_8a4vc")]
|
||||
position = Vector2(0, 990)
|
||||
|
||||
|
@@ -5,6 +5,7 @@ var root: Node
|
||||
var has_fade_away: bool = false
|
||||
|
||||
@export var area2d: Area2D
|
||||
@export var collision_shape: CollisionShape2D
|
||||
@export var collectable_data: CollectableResource
|
||||
@export var sfx: AudioStreamPlayer2D
|
||||
signal collected(amount: int, type: CollectableResource.CollectableType)
|
||||
@@ -25,6 +26,8 @@ func _ready() -> void:
|
||||
func _on_area2d_body_entered(body: Node2D) -> void:
|
||||
if body.has_node("CanPickUpComponent"):
|
||||
collected.emit(collectable_data.amount, collectable_data.type)
|
||||
if collision_shape:
|
||||
collision_shape.call_deferred("set_disabled", true)
|
||||
if sfx:
|
||||
sfx.play()
|
||||
if not has_fade_away:
|
||||
|
@@ -123,3 +123,15 @@ func unlock_level(level_index: int) -> void:
|
||||
func try_to_go_to_next_level() -> void:
|
||||
if player_state["current_level"] + 1 < level_scenes.size() and player_state["current_level"] + 1 in player_state["unlocked_levels"]:
|
||||
player_state["current_level"] += 1
|
||||
|
||||
|
||||
func quit_game() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func pause_game() -> void:
|
||||
Engine.time_scale = 0
|
||||
|
||||
|
||||
func resume_game() -> void:
|
||||
Engine.time_scale = 1
|
85
scripts/pause_menu.gd
Normal file
85
scripts/pause_menu.gd
Normal file
@@ -0,0 +1,85 @@
|
||||
class_name PauseMenu
|
||||
extends Node
|
||||
|
||||
@export var pause_menu_control: Control
|
||||
@export var resume_button: Button
|
||||
@export var quit_button: Button
|
||||
@export var settings_button: Button
|
||||
@export var exit_to_menu_button: Button
|
||||
@export var settings_menu: PackedScene
|
||||
@export var exit_to_menu_scene: PackedScene
|
||||
|
||||
@onready var gm: GM = $"/root/GameManager"
|
||||
|
||||
var is_paused: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if not pause_menu_control:
|
||||
printerr("PauseMenu: Pause menu control not set.")
|
||||
return
|
||||
|
||||
if not resume_button:
|
||||
printerr("PauseMenu: Resume button not set.")
|
||||
return
|
||||
|
||||
if not quit_button:
|
||||
printerr("PauseMenu: Quit button not set.")
|
||||
return
|
||||
|
||||
if not settings_button:
|
||||
printerr("PauseMenu: Settings button not set.")
|
||||
return
|
||||
|
||||
if not exit_to_menu_button:
|
||||
printerr("PauseMenu: Exit to menu button not set.")
|
||||
return
|
||||
|
||||
pause_menu_control.hide()
|
||||
|
||||
resume_button.pressed.connect(_on_resume_button_pressed)
|
||||
quit_button.pressed.connect(_on_quit_button_pressed)
|
||||
settings_button.pressed.connect(_on_settings_button_pressed)
|
||||
exit_to_menu_button.pressed.connect(_on_exit_to_menu_button_pressed)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("pause"):
|
||||
if is_paused:
|
||||
_on_resume_button_pressed()
|
||||
else:
|
||||
gm.pause_game()
|
||||
is_paused = true
|
||||
pause_menu_control.show()
|
||||
resume_button.grab_focus()
|
||||
|
||||
|
||||
func _on_resume_button_pressed() -> void:
|
||||
pause_menu_control.hide()
|
||||
gm.resume_game()
|
||||
is_paused = false
|
||||
|
||||
|
||||
func _on_quit_button_pressed() -> void:
|
||||
gm.quit_game()
|
||||
|
||||
|
||||
func _on_settings_button_pressed() -> void:
|
||||
if not settings_menu:
|
||||
printerr("PauseMenu: Settings menu scene not set.")
|
||||
return
|
||||
|
||||
var settings_instance: Control = settings_menu.instantiate()
|
||||
get_tree().root.add_child(settings_instance)
|
||||
settings_instance.show()
|
||||
pause_menu_control.hide()
|
||||
gm.pause_game()
|
||||
is_paused = true
|
||||
|
||||
|
||||
func _on_exit_to_menu_button_pressed() -> void:
|
||||
if not exit_to_menu_scene:
|
||||
printerr("PauseMenu: Exit to menu scene not set.")
|
||||
return
|
||||
|
||||
get_tree().change_scene_to_packed(exit_to_menu_scene)
|
1
scripts/pause_menu.gd.uid
Normal file
1
scripts/pause_menu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cugifchx6jhuk
|
Reference in New Issue
Block a user