This commit is contained in:
Victor Turgeon 2022-10-11 15:00:18 -04:00
commit 8975fbed27
5 changed files with 138 additions and 58 deletions

117
HUD.tscn
View File

@ -1,16 +1,9 @@
[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://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
@ -22,17 +15,6 @@ 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
outline_color = Color( 0, 0, 0, 1 )
use_mipmaps = true
use_filter = true
font_data = ExtResource( 3 )
[sub_resource type="Theme" id=10]
default_font = SubResource( 9 )
[sub_resource type="Shader" id=6]
code = "shader_type canvas_item;
render_mode unshaded;
@ -69,40 +51,20 @@ 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=12]
size = 33
use_filter = true
font_data = ExtResource( 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 )
[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"
follow_viewport_enable = true
[node name="ActualHUD" type="Control" parent="."]
anchor_left = 0.037
@ -111,7 +73,7 @@ anchor_right = 0.037
anchor_bottom = 0.916
margin_right = 40.0
margin_bottom = 40.0
theme = SubResource( 10 )
theme = SubResource( 8 )
[node name="SlapGauge" type="ColorRect" parent="ActualHUD"]
material = SubResource( 11 )
@ -130,3 +92,50 @@ margin_top = -169.452
margin_right = -3572.2
margin_bottom = -137.452
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 = -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"]
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 = 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 = 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 = 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"]
[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"]

View File

@ -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;
@ -29,6 +30,13 @@ onready var slap_animator = $HandMovement
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
slap_animator.current_animation = "basic_slap"
onready var SlapGauge = $HUD/ActualHUD/SlapGauge
onready var Menu = $HUD/Start
onready var AudioSlap = $AudioSlap
onready var AudioMegaSlap = $AudioMegaSlap
func _ready():
pass
func _input(event):
if event is InputEventMouseMotion:
@ -39,6 +47,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
@ -58,7 +69,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
@ -72,13 +82,22 @@ 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"):
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:
@ -87,6 +106,9 @@ func _physics_process(delta):
slap_gauge.fill = slap
slap_animator.seek(slap, true)
SlapGauge.fill = slap;
SlapGauge.kill = slapkill;
direction = direction.normalized()
h_velocity = h_velocity.linear_interpolate(direction * speed, h_acceleration * delta)

View File

@ -4,6 +4,8 @@
[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
@ -118,3 +120,8 @@ cast_to = Vector3( 0, -1.5, 0 )
[node name="HandMovement" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 5 )
anims/basic_slap = SubResource( 6 )
[node name="AudioSlap" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource( 5 )
[node name="AudioMegaSlap" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource( 6 )

37
Start.gd Normal file
View File

@ -0,0 +1,37 @@
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 = 664
QuitDesktop.margin_bottom = 708
self.show()
get_tree().paused = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
func _on_Quit_Game_pressed():
get_tree().reload_current_scene()

View File

@ -69,6 +69,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]