Merge remote-tracking branch 'origin/dev-sounds' into devRefactor

This commit is contained in:
Streamfire
2020-04-19 11:42:54 +02:00
20 changed files with 222 additions and 22 deletions

View File

@@ -5,17 +5,25 @@ This is an example player controller script created by Paul
"""
var velocity := Vector2.ZERO
var rollvector := Vector2.ZERO
# This is how you export variables with ranges to the editor window
export(bool) var debug := false
export(int, 0, 500) var ROLL_SPEED := 150
export(int, 0, 500) var FRICTION := 200 # Speed at which the player deaccelarates
export(int, 0, 500) var ACCELERATION := 450
# Reference for the current player
# Reference for the current player
onready var player_stats := $Stats
onready var debug_label := $DebugLabel
onready var animation_state := $AnimationStates
# Variables for sound selection
onready var walk_sounds = $Sounds/Walk
onready var walk_sound_timer = $Sounds/WalkSoundTimer
var _rng = RandomNumberGenerator.new()
var is_playing_sound = false
enum moveState{
MOVE,
ROLL,
@@ -82,6 +90,7 @@ func movement_move(delta):
animation_state.change_state("run")
velocity = velocity.move_toward(player_stats.speed * input_vector, ACCELERATION * delta)
_play_random_sound(walk_sounds)
if Input.is_action_just_pressed("roll"):
movementState = moveState.ROLL
elif Input.is_action_just_pressed("attack"):
@@ -129,3 +138,28 @@ func _on_Hitbox_area_entered(area):
currency += area.currency_value
player_stats.health = player_stats.health+area.health_value
player_stats.speed -= area.slowdown_value
func _walk_sound_finished():
is_playing_sound = false
func _walk_sound_wait_time():
var x = abs(velocity.length() / 100) - 1
return log(((x+1)/4)+2.5) / 3
# TODO: Rework anyone
func _play_random_sound(path = walk_sounds):
if walk_sound_timer.is_stopped() and not is_playing_sound:
var sound = path.get_children()[_rng.randi_range(0, path.get_child_count() - 1)]
sound.play()
is_playing_sound = true
walk_sound_timer.start(_walk_sound_wait_time())
print(_walk_sound_wait_time())
# Overrides ready method for this entire script, checks for the finished method of each possible sound
func _ready():
for child in walk_sounds.get_children():
child.connect("finished", self, "_walk_sound_finished")

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=61 format=2]
[gd_scene load_steps=66 format=2]
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
@@ -6,11 +6,16 @@
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=4]
[ext_resource path="res://Overlap/Stats/Stats.tscn" type="PackedScene" id=5]
[ext_resource path="res://Fonts/Harmonic/Harmonic.ttf" type="DynamicFontData" id=6]
[ext_resource path="res://Player/States/Idle.gd" type="Script" id=7]
[ext_resource path="res://Player/States/Attack.gd" type="Script" id=8]
[ext_resource path="res://Player/States/Roll.gd" type="Script" id=9]
[ext_resource path="res://Player/States/Run.gd" type="Script" id=10]
[ext_resource path="res://Player/PlayerStateMachine.gd" type="Script" id=11]
[ext_resource path="res://Player/Sounds/hero_walk_3.ogg" type="AudioStream" id=7]
[ext_resource path="res://Player/Sounds/hero_walk_5.ogg" type="AudioStream" id=8]
[ext_resource path="res://Player/Sounds/hero_walk_4.ogg" type="AudioStream" id=9]
[ext_resource path="res://Player/Sounds/hero_walk_2.ogg" type="AudioStream" id=10]
[ext_resource path="res://Player/Sounds/hero_walk_1.ogg" type="AudioStream" id=11]
[ext_resource path="res://Player/States/Idle.gd" type="Script" id=12]
[ext_resource path="res://Player/States/Run.gd" type="Script" id=13]
[ext_resource path="res://Player/States/Attack.gd" type="Script" id=14]
[ext_resource path="res://Player/PlayerStateMachine.gd" type="Script" id=15]
[ext_resource path="res://Player/States/Roll.gd" type="Script" id=16]
[sub_resource type="CapsuleShape2D" id=1]
radius = 2.15976
@@ -715,20 +720,42 @@ __meta__ = {
max_health = 5
[node name="AnimationStates" type="Node" parent="."]
script = ExtResource( 11 )
script = ExtResource( 15 )
START_STATE = NodePath("Idle")
[node name="Run" type="Node" parent="AnimationStates"]
script = ExtResource( 10 )
script = ExtResource( 13 )
[node name="Idle" type="Node" parent="AnimationStates"]
script = ExtResource( 7 )
script = ExtResource( 12 )
[node name="Attack" type="Node" parent="AnimationStates"]
script = ExtResource( 8 )
script = ExtResource( 14 )
[node name="Roll" type="Node" parent="AnimationStates"]
script = ExtResource( 9 )
script = ExtResource( 16 )
[node name="Sounds" type="Node" parent="."]
[node name="Walk" type="Node" parent="Sounds"]
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="Sounds/Walk"]
stream = ExtResource( 11 )
[node name="AudioStreamPlayer2" type="AudioStreamPlayer" parent="Sounds/Walk"]
stream = ExtResource( 10 )
[node name="AudioStreamPlayer3" type="AudioStreamPlayer" parent="Sounds/Walk"]
stream = ExtResource( 7 )
[node name="AudioStreamPlayer4" type="AudioStreamPlayer" parent="Sounds/Walk"]
stream = ExtResource( 9 )
[node name="AudioStreamPlayer5" type="AudioStreamPlayer" parent="Sounds/Walk"]
stream = ExtResource( 8 )
[node name="WalkSoundTimer" type="Timer" parent="Sounds"]
one_shot = true
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]

Binary file not shown.

View File

@@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/hero_walk_1.ogg-189348d983150ee57f2f6f423ab41c11.oggstr"
[deps]
source_file="res://Player/Sounds/hero_walk_1.ogg"
dest_files=[ "res://.import/hero_walk_1.ogg-189348d983150ee57f2f6f423ab41c11.oggstr" ]
[params]
loop=false
loop_offset=0

Binary file not shown.

View File

@@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/hero_walk_2.ogg-e1d0be2a03d2db5f284fb29ec53c5da6.oggstr"
[deps]
source_file="res://Player/Sounds/hero_walk_2.ogg"
dest_files=[ "res://.import/hero_walk_2.ogg-e1d0be2a03d2db5f284fb29ec53c5da6.oggstr" ]
[params]
loop=false
loop_offset=0

Binary file not shown.

View File

@@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/hero_walk_3.ogg-814c846ca66fb1f14e78fa6b00b87e97.oggstr"
[deps]
source_file="res://Player/Sounds/hero_walk_3.ogg"
dest_files=[ "res://.import/hero_walk_3.ogg-814c846ca66fb1f14e78fa6b00b87e97.oggstr" ]
[params]
loop=false
loop_offset=0

Binary file not shown.

View File

@@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/hero_walk_4.ogg-9e50819f5b58783431785fe51bc32400.oggstr"
[deps]
source_file="res://Player/Sounds/hero_walk_4.ogg"
dest_files=[ "res://.import/hero_walk_4.ogg-9e50819f5b58783431785fe51bc32400.oggstr" ]
[params]
loop=false
loop_offset=0

Binary file not shown.

View File

@@ -0,0 +1,15 @@
[remap]
importer="ogg_vorbis"
type="AudioStreamOGGVorbis"
path="res://.import/hero_walk_5.ogg-5ad7e7c78f2b3d0ff4c89ac846546604.oggstr"
[deps]
source_file="res://Player/Sounds/hero_walk_5.ogg"
dest_files=[ "res://.import/hero_walk_5.ogg-5ad7e7c78f2b3d0ff4c89ac846546604.oggstr" ]
[params]
loop=false
loop_offset=0