From 0433b2c7c0202595ef34c8bf71bf9c47c10dd265 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Tue, 11 Oct 2022 14:32:39 -0400 Subject: [PATCH 1/3] 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] From 06ad712fd967eac2cfcc7bf98df6dffe3a9e34b6 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Tue, 11 Oct 2022 14:37:43 -0400 Subject: [PATCH 2/3] What did the five finger say to the face? SLAP! --- Player.gd | 5 +++-- Start.gd | 3 --- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Player.gd b/Player.gd index c3f53fb..116b656 100644 --- a/Player.gd +++ b/Player.gd @@ -73,8 +73,9 @@ func _physics_process(delta): direction += transform.basis.x # Slappening - if Input.is_action_just_pressed("slap"): - chargeSlap = true; + if Input.is_action_pressed("slap"): + if slap < 0.01: + chargeSlap = true; elif Input.is_action_just_released("slap"): chargeSlap = false; isSlap = true; diff --git a/Start.gd b/Start.gd index 4eb8c77..31afae9 100644 --- a/Start.gd +++ b/Start.gd @@ -12,7 +12,6 @@ func _ready(): QuitDesktop.margin_bottom -= 44 Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - func _on_Quit_to_Desktop_Button_pressed(): get_tree().quit() @@ -34,7 +33,5 @@ func openMenu(): get_tree().paused = true Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - - func _on_Quit_Game_pressed(): get_tree().reload_current_scene() From 286abb5032180f61236dc2c5db317066f8aa4633 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Tue, 11 Oct 2022 14:57:56 -0400 Subject: [PATCH 3/3] AUDIOSLAP --- HUD.tscn | 82 +++++++++++++++++++++++---------------------------- Player.gd | 16 ++++++++-- Player.tscn | 10 ++++++- Start.gd | 4 +-- project.godot | 3 ++ 5 files changed, 65 insertions(+), 50 deletions(-) diff --git a/HUD.tscn b/HUD.tscn index 9dea12a..9a1a0dc 100644 --- a/HUD.tscn +++ b/HUD.tscn @@ -1,10 +1,10 @@ -[gd_scene load_steps=11 format=2] +[gd_scene load_steps=10 format=2] [ext_resource path="res://SlapGauge.gd" type="Script" id=1] [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=9] +[sub_resource type="DynamicFont" id=4] size = 19 outline_size = 2 outline_color = Color( 0, 0, 0, 1 ) @@ -12,8 +12,8 @@ use_mipmaps = true use_filter = true font_data = ExtResource( 3 ) -[sub_resource type="Theme" id=10] -default_font = SubResource( 9 ) +[sub_resource type="Theme" id=8] +default_font = SubResource( 4 ) [sub_resource type="Shader" id=6] code = "shader_type canvas_item; @@ -51,17 +51,11 @@ 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 +[sub_resource type="DynamicFont" id=12] +size = 33 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 @@ -70,11 +64,12 @@ use_filter = true font_data = ExtResource( 3 ) [node name="HUD" type="CanvasLayer"] +follow_viewport_enable = true [node name="ActualHUD" type="Control" parent="."] margin_right = 40.0 margin_bottom = 40.0 -theme = SubResource( 10 ) +theme = SubResource( 8 ) [node name="SlapGauge" type="ColorRect" parent="ActualHUD"] material = SubResource( 11 ) @@ -82,10 +77,10 @@ anchor_left = 12.875 anchor_top = 7.625 anchor_right = 12.875 anchor_bottom = 7.625 -margin_left = -451.0 -margin_top = 218.0 -margin_right = -161.0 -margin_bottom = 241.0 +margin_left = -464.0 +margin_top = 666.0 +margin_right = 114.0 +margin_bottom = 699.0 script = ExtResource( 1 ) [node name="SlapLabel" type="Label" parent="ActualHUD"] @@ -94,10 +89,11 @@ anchor_left = 12.662 anchor_top = 7.324 anchor_right = 12.662 anchor_bottom = 7.324 -margin_left = -436.48 -margin_top = 229.04 -margin_right = -325.48 -margin_bottom = 261.04 +margin_left = -441.48 +margin_top = 673.04 +margin_right = -380.48 +margin_bottom = 712.04 +custom_fonts/font = SubResource( 12 ) text = "Slap" [node name="Start" type="Control" parent="."] @@ -108,43 +104,39 @@ 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 +margin_left = -4.0 +margin_top = -8.0 +margin_right = 1927.0 +margin_bottom = 1085.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 +margin_left = 532.0 +margin_top = 353.0 +margin_right = 1414.0 +margin_bottom = 455.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 +margin_left = 886.0 +margin_top = 554.0 +margin_right = 1061.0 +margin_bottom = 598.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 +margin_left = 887.0 +margin_top = 664.0 +margin_right = 1062.0 +margin_bottom = 708.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 +margin_left = 887.0 +margin_top = 609.0 +margin_right = 1062.0 +margin_bottom = 653.0 text = "Quit Game" [connection signal="pressed" from="Start/New Game" to="Start" method="_on_New_Game_pressed"] diff --git a/Player.gd b/Player.gd index 116b656..c1b7652 100644 --- a/Player.gd +++ b/Player.gd @@ -7,6 +7,7 @@ export var air_acceleration = 1 export var normal_acceleration = 6 export var gravity = 100 export var jump = 30 +export var slapkill = 0.8 var slap = 0.0 var chargeSlap = false var isSlap = false; @@ -25,6 +26,8 @@ onready var head = $Head onready var ground_check = $GroundCheck onready var SlapGauge = $HUD/ActualHUD/SlapGauge onready var Menu = $HUD/Start +onready var AudioSlap = $AudioSlap +onready var AudioMegaSlap = $AudioMegaSlap func _ready(): pass @@ -77,17 +80,26 @@ func _physics_process(delta): if slap < 0.01: chargeSlap = true; elif Input.is_action_just_released("slap"): + if chargeSlap: + isSlap = true; chargeSlap = false; - isSlap = true; else: isSlap = false; + + if isSlap: + if slap >= slapkill: + AudioMegaSlap.play() + else: + AudioSlap.play() + if (chargeSlap): slap += delta * 1.5; else: slap -= delta * 8.0; slap = clamp(slap, 0.0, 1.0) SlapGauge.fill = slap; - + SlapGauge.kill = slapkill; + direction = direction.normalized() h_velocity = h_velocity.linear_interpolate(direction * speed, h_acceleration * delta) diff --git a/Player.tscn b/Player.tscn index e717002..382f16c 100644 --- a/Player.tscn +++ b/Player.tscn @@ -1,9 +1,11 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=10 format=2] [ext_resource path="res://Player.gd" type="Script" id=1] [ext_resource path="res://BlenderStuff/Hand/protohand.obj" type="ArrayMesh" id=2] [ext_resource path="res://Textures/kenney_prototype_textures/purple/texture_01.png" type="Texture" id=3] [ext_resource path="res://HUD.tscn" type="PackedScene" id=4] +[ext_resource path="res://Audio/80-s-clap.wav" type="AudioStream" id=5] +[ext_resource path="res://Audio/MegaSlap.wav" type="AudioStream" id=6] [sub_resource type="CapsuleShape" id=2] height = 3.0 @@ -44,3 +46,9 @@ enabled = true cast_to = Vector3( 0, -1.5, 0 ) [node name="HUD" parent="." instance=ExtResource( 4 )] + +[node name="AudioSlap" type="AudioStreamPlayer3D" parent="."] +stream = ExtResource( 5 ) + +[node name="AudioMegaSlap" type="AudioStreamPlayer3D" parent="."] +stream = ExtResource( 6 ) diff --git a/Start.gd b/Start.gd index 31afae9..6aea53a 100644 --- a/Start.gd +++ b/Start.gd @@ -26,8 +26,8 @@ func openMenu(): NewGame.set_text("Continue Game") QuitGame.show(); - QuitDesktop.margin_top = 491 - QuitDesktop.margin_bottom = 535 + QuitDesktop.margin_top = 664 + QuitDesktop.margin_bottom = 708 self.show() get_tree().paused = true diff --git a/project.godot b/project.godot index cd6172a..ff93292 100644 --- a/project.godot +++ b/project.godot @@ -16,6 +16,9 @@ config/icon="res://icon.png" [display] +window/size/width=1920 +window/size/height=1080 +window/size/fullscreen=true window/stretch/aspect="keep" [gui]