Added some player sounds
This commit is contained in:
@@ -2,10 +2,10 @@ class_name Player
|
||||
extends CharacterBody2D
|
||||
|
||||
|
||||
@export_group("Movement", "movement")
|
||||
@export_range(0.0, 1000.0) var movement_max_speed_normal := 350
|
||||
@export_range(0.0, 1000.0) var movement_max_speed_after_attack := 250
|
||||
@export_range(0.0, 1000.0) var movement_acceleration := 1000.0
|
||||
@export_group("Movement", "move")
|
||||
@export_range(0.0, 1000.0) var move_max_speed_normal := 350
|
||||
@export_range(0.0, 1000.0) var move_max_speed_slowed := 250
|
||||
@export_range(0.0, 1000.0) var move_acceleration := 1000.0
|
||||
|
||||
@export_group("Jump", "jump")
|
||||
@export_range(0.0, 1000.0) var jump_max_fall_speed := 1000
|
||||
@@ -44,12 +44,19 @@ var _last_wall_normal: = 0.0
|
||||
@onready var wall_attach_timer : Timer = $WallAttachTimer
|
||||
@onready var attack_cooldown_timer : Timer = $AttackCooldownTimer
|
||||
|
||||
@onready var _max_speed := movement_max_speed_normal
|
||||
@onready var _max_speed := move_max_speed_normal
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
state_machine.init()
|
||||
|
||||
for sprite : AnimatedSprite2D in [ attack_left_sprite, attack_right_sprite ]:
|
||||
var lambda := func() -> void:
|
||||
sprite.hide()
|
||||
blade_sprite.show()
|
||||
sprite.animation_finished.connect(lambda)
|
||||
sprite.hide()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if is_on_floor():
|
||||
@@ -87,18 +94,20 @@ func _physics_process(delta: float) -> void:
|
||||
velocity.y = -jump_floor_velocity
|
||||
jump_buffer_timer.stop()
|
||||
floor_coyote_time_timer.stop()
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_jump, global_position)
|
||||
elif not wall_coyote_time_timer.is_stopped():
|
||||
velocity = -jump_wall_velocity
|
||||
velocity.x *= -_last_wall_normal
|
||||
jump_buffer_timer.stop()
|
||||
wall_coyote_time_timer.stop()
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_wall_jump, global_position)
|
||||
|
||||
|
||||
if input_direction:
|
||||
var input_velocity := input_direction * _max_speed
|
||||
velocity.x = move_toward(velocity.x, input_velocity, movement_acceleration * delta)
|
||||
velocity.x = move_toward(velocity.x, input_velocity, move_acceleration * delta)
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, movement_acceleration * delta)
|
||||
velocity.x = move_toward(velocity.x, 0, move_acceleration * delta)
|
||||
|
||||
move_and_slide()
|
||||
state_machine.physics_process(delta)
|
||||
@@ -107,11 +116,20 @@ func _physics_process(delta: float) -> void:
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("attack"):
|
||||
if not _slow_down_tween or not _slow_down_tween.is_running():
|
||||
print("Attack")
|
||||
if not is_on_floor() or not is_zero_approx(velocity.x):
|
||||
_attack()
|
||||
|
||||
|
||||
func _attack() -> void:
|
||||
var sprite := attack_left_sprite if velocity.x <= 0.0 else attack_right_sprite
|
||||
sprite.show()
|
||||
blade_sprite.hide()
|
||||
sprite.play("attack")
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_swing, global_position)
|
||||
|
||||
_slow_down_tween = create_tween()
|
||||
_slow_down_tween.tween_property(self, "_max_speed", \
|
||||
movement_max_speed_after_attack, slow_down_attack)
|
||||
_slow_down_tween.tween_property(self, "_max_speed", \
|
||||
movement_max_speed_after_attack, slow_down_sustain)
|
||||
_slow_down_tween.tween_property(self, "_max_speed", \
|
||||
movement_max_speed_normal, slow_down_release)
|
||||
_slow_down_tween.tween_property(self, "_max_speed", move_max_speed_slowed, slow_down_attack)
|
||||
_slow_down_tween.tween_property(self, "_max_speed", move_max_speed_slowed, slow_down_sustain)
|
||||
_slow_down_tween.tween_property(self, "_max_speed", move_max_speed_normal, slow_down_release)
|
||||
_slow_down_tween.tween_property(sprite, "visible", false, 0.0)
|
||||
|
||||
|
||||
@@ -399,37 +399,34 @@ animations = [{
|
||||
"speed": 10.0
|
||||
}]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_oic1i"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(96, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_v0nmi"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(112, 0, 16, 32)
|
||||
region = Rect2(0, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dhej3"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(128, 0, 16, 32)
|
||||
region = Rect2(16, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kn1iv"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(144, 0, 16, 32)
|
||||
region = Rect2(32, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5wwt0"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(160, 0, 16, 32)
|
||||
region = Rect2(48, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_igs2l"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(176, 0, 16, 32)
|
||||
region = Rect2(64, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fckvs"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(80, 0, 16, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_sn0t7"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_oic1i")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_v0nmi")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
@@ -443,15 +440,63 @@ animations = [{
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_igs2l")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fckvs")
|
||||
}],
|
||||
"loop": 0,
|
||||
"name": &"attack",
|
||||
"speed": 20.0
|
||||
}]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_30eym"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(96, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mitd3"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(112, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_r7to5"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(128, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uuaq0"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(144, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1gfjr"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(160, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uuiqd"]
|
||||
atlas = ExtResource("2_cjfdk")
|
||||
region = Rect2(176, 0, 16, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_i4f54"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_30eym")
|
||||
}, {
|
||||
"frames": [],
|
||||
"loop": 1,
|
||||
"name": &"default",
|
||||
"speed": 5.0
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_mitd3")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_r7to5")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_uuaq0")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1gfjr")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_uuiqd")
|
||||
}],
|
||||
"loop": 0,
|
||||
"name": &"attack",
|
||||
"speed": 20.0
|
||||
}]
|
||||
|
||||
[node name="Player" type="CharacterBody2D" unique_id=763780926]
|
||||
@@ -471,10 +516,14 @@ sprite_frames = SubResource("SpriteFrames_riqys")
|
||||
animation = &"jump_right"
|
||||
|
||||
[node name="AttackLeftSprite" type="AnimatedSprite2D" parent="." unique_id=444979654]
|
||||
position = Vector2(-16, 0)
|
||||
sprite_frames = SubResource("SpriteFrames_sn0t7")
|
||||
animation = &"attack"
|
||||
|
||||
[node name="AttackRightSprite" type="AnimatedSprite2D" parent="." unique_id=864909741]
|
||||
sprite_frames = SubResource("SpriteFrames_sn0t7")
|
||||
position = Vector2(16, 0)
|
||||
sprite_frames = SubResource("SpriteFrames_i4f54")
|
||||
animation = &"attack"
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="." unique_id=1654451713]
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ func physics_process(_delta: float) -> void:
|
||||
switch_state.emit(running_right)
|
||||
else:
|
||||
if is_zero_approx(player.velocity.x):
|
||||
switch_state.emit([jump_left, jump_right].pick_random())
|
||||
switch_state.emit(jump_left)
|
||||
elif player.velocity.x < 0.0:
|
||||
switch_state.emit(jump_left)
|
||||
elif player.velocity.x > 0.0:
|
||||
|
||||
@@ -32,6 +32,7 @@ func exit() -> void:
|
||||
|
||||
func physics_process(_delta: float) -> void:
|
||||
if player.is_on_floor():
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_land, player.global_position)
|
||||
if is_zero_approx(player.velocity.x):
|
||||
switch_state.emit(idle)
|
||||
else:
|
||||
|
||||
@@ -44,7 +44,7 @@ func physics_process(_delta: float) -> void:
|
||||
switch_state.emit(another_direction)
|
||||
else:
|
||||
if is_zero_approx(player.velocity.x):
|
||||
switch_state.emit([jump, jump_another_direction].pick_random())
|
||||
switch_state.emit(jump if direction == Direction.Left else jump_another_direction)
|
||||
else:
|
||||
match direction:
|
||||
Direction.Left:
|
||||
|
||||
@@ -24,6 +24,10 @@ const MUSIC_BUS = "Music"
|
||||
@export var ui_stream_select : AudioStream
|
||||
|
||||
@export_group("SFX Streams", "sfx_stream")
|
||||
@export var sfx_stream_jump : AudioStream
|
||||
@export var sfx_stream_land : AudioStream
|
||||
@export var sfx_stream_swing : AudioStream
|
||||
@export var sfx_stream_wall_jump : AudioStream
|
||||
|
||||
|
||||
@export_group("Music Streams", "music_stream")
|
||||
|
||||
@@ -4,16 +4,24 @@
|
||||
[ext_resource type="AudioStream" uid="uid://cwmibbhy2fpq2" path="res://sound/ui/accept.wav" id="2_ge1il"]
|
||||
[ext_resource type="AudioStream" uid="uid://d2tsomsqmhf0h" path="res://sound/ui/decline.wav" id="3_agyxs"]
|
||||
[ext_resource type="AudioStream" uid="uid://cfb2adf5hft7b" path="res://sound/ui/select.wav" id="4_0i6kl"]
|
||||
[ext_resource type="AudioStream" uid="uid://bcc0textvn2lx" path="res://sound/sfx/jump.wav" id="5_fpnh3"]
|
||||
[ext_resource type="AudioStream" uid="uid://b6xkhskx5gi0w" path="res://sound/sfx/land.wav" id="6_22ptj"]
|
||||
[ext_resource type="AudioStream" uid="uid://bj6ausg5hyuyg" path="res://sound/sfx/swing.wav" id="7_ab171"]
|
||||
[ext_resource type="AudioStream" uid="uid://33unutlwsika" path="res://sound/sfx/wall_jump.wav" id="8_22ptj"]
|
||||
|
||||
[node name="SoundManager" type="Node" unique_id=1576371552]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_cg0sy")
|
||||
pitch_ui_min = 0.9500000000000001
|
||||
pitch_ui_min = 0.95
|
||||
pitch_ui_max = 1.05
|
||||
pitch_sfx_min = 0.9500000000000001
|
||||
pitch_sfx_min = 0.95
|
||||
pitch_sfx_max = 1.05
|
||||
player_count_ui = 8
|
||||
player_count_sfx = 32
|
||||
ui_stream_accept = ExtResource("2_ge1il")
|
||||
ui_stream_decline = ExtResource("3_agyxs")
|
||||
ui_stream_select = ExtResource("4_0i6kl")
|
||||
sfx_stream_jump = ExtResource("5_fpnh3")
|
||||
sfx_stream_land = ExtResource("6_22ptj")
|
||||
sfx_stream_swing = ExtResource("7_ab171")
|
||||
sfx_stream_wall_jump = ExtResource("8_22ptj")
|
||||
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bcc0textvn2lx"
|
||||
path="res://.godot/imported/jump.wav-89eafde76b4d0550c115f0c423080c9e.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sound/sfx/jump.wav"
|
||||
dest_files=["res://.godot/imported/jump.wav-89eafde76b4d0550c115f0c423080c9e.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://b6xkhskx5gi0w"
|
||||
path="res://.godot/imported/land.wav-793066395dcd81cab1092777a627b5e2.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sound/sfx/land.wav"
|
||||
dest_files=["res://.godot/imported/land.wav-793066395dcd81cab1092777a627b5e2.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://bj6ausg5hyuyg"
|
||||
path="res://.godot/imported/swing.wav-924862408749129969b9ba9e3427e2ee.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sound/sfx/swing.wav"
|
||||
dest_files=["res://.godot/imported/swing.wav-924862408749129969b9ba9e3427e2ee.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://33unutlwsika"
|
||||
path="res://.godot/imported/wall_jump.wav-527fcadc0831fa49732410db24acca8a.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sound/sfx/wall_jump.wav"
|
||||
dest_files=["res://.godot/imported/wall_jump.wav-527fcadc0831fa49732410db24acca8a.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
Reference in New Issue
Block a user