mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-18 08:00:19 +02:00
Added walk sounds for the player
This commit is contained in:
@@ -5,18 +5,25 @@ This is an example player controller script created by Paul
|
|||||||
"""
|
"""
|
||||||
var velocity := Vector2.ZERO
|
var velocity := Vector2.ZERO
|
||||||
var rollvector := Vector2.ZERO
|
var rollvector := Vector2.ZERO
|
||||||
|
|
||||||
# This is how you export variables with ranges to the editor window
|
# This is how you export variables with ranges to the editor window
|
||||||
export(int, 0, 500) var ROLL_SPEED := 150
|
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 FRICTION := 200 # Speed at which the player deaccelarates
|
||||||
export(int, 0, 500) var ACCELERATION := 450
|
export(int, 0, 500) var ACCELERATION := 450
|
||||||
# Reference for the current player
|
|
||||||
|
|
||||||
|
# Reference for the current player
|
||||||
onready var player_stats := $Stats
|
onready var player_stats := $Stats
|
||||||
onready var debug_label := $DebugLabel
|
onready var debug_label := $DebugLabel
|
||||||
onready var animation_player := $AnimationPlayer
|
onready var animation_player := $AnimationPlayer
|
||||||
onready var animation_tree := $AnimationTree
|
onready var animation_tree := $AnimationTree
|
||||||
onready var animation_state = animation_tree.get("parameters/playback")
|
onready var animation_state = animation_tree.get("parameters/playback")
|
||||||
|
|
||||||
|
# Variables for sound selection
|
||||||
|
onready var walk_sounds = $Sounds/Walk
|
||||||
|
var _rng = RandomNumberGenerator.new()
|
||||||
|
var is_playing_sound = false
|
||||||
|
|
||||||
|
|
||||||
enum moveState{
|
enum moveState{
|
||||||
MOVE,
|
MOVE,
|
||||||
ROLL,
|
ROLL,
|
||||||
@@ -83,6 +90,7 @@ func movement_move(delta):
|
|||||||
animation_tree.set("parameters/run/blend_position", input_vector)
|
animation_tree.set("parameters/run/blend_position", input_vector)
|
||||||
animation_state.travel("run")
|
animation_state.travel("run")
|
||||||
velocity = velocity.move_toward(player_stats.speed * input_vector, ACCELERATION * delta)
|
velocity = velocity.move_toward(player_stats.speed * input_vector, ACCELERATION * delta)
|
||||||
|
_play_random_sound(walk_sounds)
|
||||||
if Input.is_action_just_pressed("roll"):
|
if Input.is_action_just_pressed("roll"):
|
||||||
movementState = moveState.ROLL
|
movementState = moveState.ROLL
|
||||||
elif Input.is_action_just_pressed("attack"):
|
elif Input.is_action_just_pressed("attack"):
|
||||||
@@ -120,3 +128,20 @@ func _on_Hitbox_area_entered(area):
|
|||||||
currency += area.currency_value
|
currency += area.currency_value
|
||||||
player_stats.health = player_stats.health+area.health_value
|
player_stats.health = player_stats.health+area.health_value
|
||||||
player_stats.speed -= area.slowdown_value
|
player_stats.speed -= area.slowdown_value
|
||||||
|
|
||||||
|
|
||||||
|
func _walk_sound_finished():
|
||||||
|
is_playing_sound = false
|
||||||
|
|
||||||
|
|
||||||
|
func _play_random_sound(path = walk_sounds):
|
||||||
|
if not is_playing_sound:
|
||||||
|
var sound = path.get_children()[_rng.randi_range(0, path.get_child_count() - 1)]
|
||||||
|
sound.play()
|
||||||
|
is_playing_sound = true
|
||||||
|
|
||||||
|
|
||||||
|
# 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")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=56 format=2]
|
[gd_scene load_steps=61 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
|
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
|
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
|
||||||
@@ -6,6 +6,11 @@
|
|||||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=4]
|
[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://Overlap/Stats/Stats.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://Fonts/Harmonic/Harmonic.ttf" type="DynamicFontData" id=6]
|
[ext_resource path="res://Fonts/Harmonic/Harmonic.ttf" type="DynamicFontData" id=6]
|
||||||
|
[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]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=1]
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
radius = 2.15976
|
radius = 2.15976
|
||||||
@@ -707,6 +712,25 @@ __meta__ = {
|
|||||||
|
|
||||||
[node name="Stats" parent="." instance=ExtResource( 5 )]
|
[node name="Stats" parent="." instance=ExtResource( 5 )]
|
||||||
max_health = 5
|
max_health = 5
|
||||||
|
|
||||||
|
[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 )
|
||||||
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
|
[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_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
|
||||||
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
|
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
|
||||||
|
|||||||
BIN
src/Player/Sounds/hero_walk_1.ogg
Normal file
BIN
src/Player/Sounds/hero_walk_1.ogg
Normal file
Binary file not shown.
15
src/Player/Sounds/hero_walk_1.ogg.import
Normal file
15
src/Player/Sounds/hero_walk_1.ogg.import
Normal 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
|
||||||
BIN
src/Player/Sounds/hero_walk_2.ogg
Normal file
BIN
src/Player/Sounds/hero_walk_2.ogg
Normal file
Binary file not shown.
15
src/Player/Sounds/hero_walk_2.ogg.import
Normal file
15
src/Player/Sounds/hero_walk_2.ogg.import
Normal 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
|
||||||
BIN
src/Player/Sounds/hero_walk_3.ogg
Normal file
BIN
src/Player/Sounds/hero_walk_3.ogg
Normal file
Binary file not shown.
15
src/Player/Sounds/hero_walk_3.ogg.import
Normal file
15
src/Player/Sounds/hero_walk_3.ogg.import
Normal 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
|
||||||
BIN
src/Player/Sounds/hero_walk_4.ogg
Normal file
BIN
src/Player/Sounds/hero_walk_4.ogg
Normal file
Binary file not shown.
15
src/Player/Sounds/hero_walk_4.ogg.import
Normal file
15
src/Player/Sounds/hero_walk_4.ogg.import
Normal 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
|
||||||
BIN
src/Player/Sounds/hero_walk_5.ogg
Normal file
BIN
src/Player/Sounds/hero_walk_5.ogg
Normal file
Binary file not shown.
15
src/Player/Sounds/hero_walk_5.ogg.import
Normal file
15
src/Player/Sounds/hero_walk_5.ogg.import
Normal 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
|
||||||
Reference in New Issue
Block a user