Merge branch 'main' of https://github.com/MarcEricMartel/FirstPersonSlapper
This commit is contained in:
30
Player.gd
30
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;
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user