From 0433b2c7c0202595ef34c8bf71bf9c47c10dd265 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Tue, 11 Oct 2022 14:32:39 -0400 Subject: [PATCH] Mennu --- HUD.tscn | 122 +++++++++++++++++++++++++++++--------------------- Player.gd | 7 ++- Start.gd | 40 +++++++++++++++++ project.godot | 5 +++ 4 files changed, 120 insertions(+), 54 deletions(-) create mode 100644 Start.gd diff --git a/HUD.tscn b/HUD.tscn index 64a0b8d..9dea12a 100644 --- a/HUD.tscn +++ b/HUD.tscn @@ -1,27 +1,9 @@ [gd_scene load_steps=11 format=2] [ext_resource path="res://SlapGauge.gd" type="Script" id=1] -[ext_resource path="res://Title Timer.gd" type="Script" id=2] +[ext_resource path="res://Start.gd" type="Script" id=2] [ext_resource path="res://fonts/TorontoSubwayRegular.ttf" type="DynamicFontData" id=3] -[sub_resource type="DynamicFont" id=7] -size = 88 -outline_size = 5 -outline_color = Color( 0, 0, 0, 1 ) -use_filter = true -font_data = ExtResource( 3 ) - -[sub_resource type="DynamicFont" id=4] -size = 19 -outline_size = 2 -outline_color = Color( 0, 0, 0, 1 ) -use_mipmaps = true -use_filter = true -font_data = ExtResource( 3 ) - -[sub_resource type="Theme" id=8] -default_font = SubResource( 4 ) - [sub_resource type="DynamicFont" id=9] size = 19 outline_size = 2 @@ -69,41 +51,26 @@ shader_param/kill = null shader_param/bkgcol = Plane( 0, 0, 0, 0.3 ) shader_param/kilcol = Plane( 0.5, 0, 0, 0.3 ) +[sub_resource type="DynamicFont" id=4] +size = 19 +outline_size = 2 +outline_color = Color( 0, 0, 0, 1 ) +use_mipmaps = true +use_filter = true +font_data = ExtResource( 3 ) + +[sub_resource type="Theme" id=8] +default_font = SubResource( 4 ) + +[sub_resource type="DynamicFont" id=7] +size = 88 +outline_size = 5 +outline_color = Color( 0, 0, 0, 1 ) +use_filter = true +font_data = ExtResource( 3 ) + [node name="HUD" type="CanvasLayer"] -[node name="Start" type="Control" parent="."] -visible = false -margin_right = 40.0 -margin_bottom = 40.0 - -[node name="Title" type="Label" parent="Start"] -anchor_left = 12.9 -anchor_top = 7.625 -anchor_right = 12.9 -anchor_bottom = 7.625 -margin_left = -439.0 -margin_top = -54.0 -margin_right = 443.0 -margin_bottom = 48.0 -custom_fonts/font = SubResource( 7 ) -text = "FIRST PERSON SLAPPER" - -[node name="Title Timer" type="Timer" parent="Start"] -one_shot = true -script = ExtResource( 2 ) - -[node name="New Game" type="Button" parent="Start"] -anchor_left = 12.85 -anchor_top = 10.525 -anchor_right = 12.85 -anchor_bottom = 10.525 -margin_left = -67.0 -margin_top = -20.0 -margin_right = 70.0 -margin_bottom = 16.0 -theme = SubResource( 8 ) -text = "New Game" - [node name="ActualHUD" type="Control" parent="."] margin_right = 40.0 margin_bottom = 40.0 @@ -132,3 +99,54 @@ margin_top = 229.04 margin_right = -325.48 margin_bottom = 261.04 text = "Slap" + +[node name="Start" type="Control" parent="."] +pause_mode = 2 +margin_right = 40.0 +margin_bottom = 40.0 +theme = SubResource( 8 ) +script = ExtResource( 2 ) + +[node name="Background" type="ColorRect" parent="Start"] +margin_left = -38.0 +margin_top = -31.0 +margin_right = 1079.0 +margin_bottom = 624.0 +color = Color( 0.14902, 0.121569, 0.121569, 1 ) + +[node name="Title" type="Label" parent="Start"] +anchor_left = 12.9 +anchor_top = 7.625 +anchor_right = 12.9 +anchor_bottom = 7.625 +margin_left = -439.0 +margin_top = -54.0 +margin_right = 443.0 +margin_bottom = 48.0 +custom_fonts/font = SubResource( 7 ) +text = "FIRST PERSON SLAPPER" + +[node name="New Game" type="Button" parent="Start"] +margin_left = 431.0 +margin_top = 393.0 +margin_right = 606.0 +margin_bottom = 437.0 +text = "New Game" + +[node name="Quit to Desktop" type="Button" parent="Start"] +margin_left = 431.0 +margin_top = 491.0 +margin_right = 606.0 +margin_bottom = 535.0 +text = "Quit to Desktop" + +[node name="Quit Game" type="Button" parent="Start"] +margin_left = 431.0 +margin_top = 442.0 +margin_right = 606.0 +margin_bottom = 486.0 +text = "Quit Game" + +[connection signal="pressed" from="Start/New Game" to="Start" method="_on_New_Game_pressed"] +[connection signal="pressed" from="Start/Quit to Desktop" to="Start" method="_on_Quit_to_Desktop_Button_pressed"] +[connection signal="pressed" from="Start/Quit Game" to="Start" method="_on_Quit_Game_pressed"] diff --git a/Player.gd b/Player.gd index e711e88..c3f53fb 100644 --- a/Player.gd +++ b/Player.gd @@ -24,9 +24,10 @@ var gravity_vec = Vector3() onready var head = $Head onready var ground_check = $GroundCheck onready var SlapGauge = $HUD/ActualHUD/SlapGauge +onready var Menu = $HUD/Start func _ready(): - Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + pass func _input(event): if event is InputEventMouseMotion: @@ -37,6 +38,9 @@ func _input(event): func _physics_process(delta): + if Input.is_action_just_pressed("escape"): + Menu.openMenu(); + if global_transform.origin.y < bottom_boudaries: global_transform.origin.x = 0 global_transform.origin.y = 10 @@ -56,7 +60,6 @@ func _physics_process(delta): gravity_vec = -get_floor_normal() h_acceleration = normal_acceleration - if Input.is_action_just_pressed("jump") and (is_on_floor() or ground_check.is_colliding()): gravity_vec = Vector3.UP * jump diff --git a/Start.gd b/Start.gd new file mode 100644 index 0000000..4eb8c77 --- /dev/null +++ b/Start.gd @@ -0,0 +1,40 @@ +extends Control + +var ingame = false +onready var NewGame = $"New Game" +onready var QuitGame = $"Quit Game" +onready var QuitDesktop = $"Quit to Desktop" + +func _ready(): + get_tree().paused = true + QuitGame.hide() + QuitDesktop.margin_top -= 44 + QuitDesktop.margin_bottom -= 44 + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + + +func _on_Quit_to_Desktop_Button_pressed(): + get_tree().quit() + +func _on_New_Game_pressed(): + self.hide() + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + get_tree().paused = false + ingame = true + +func openMenu(): + if (ingame): + NewGame.set_text("Continue Game") + QuitGame.show(); + + QuitDesktop.margin_top = 491 + QuitDesktop.margin_bottom = 535 + + self.show() + get_tree().paused = true + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + + + +func _on_Quit_Game_pressed(): + get_tree().reload_current_scene() diff --git a/project.godot b/project.godot index 15b8f86..cd6172a 100644 --- a/project.godot +++ b/project.godot @@ -64,6 +64,11 @@ slap={ "events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) ] } +escape={ +"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) + ] +} [physics]