Updated sounds + move_and_slide_with_snap enabled on player - for moving platforms

This commit is contained in:
Sagi Dayan 2020-11-06 16:05:55 -05:00
parent e49e8b57f2
commit 2e28444826
15 changed files with 102 additions and 15 deletions

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/player_attak.wav-e4631e12f4d8c16946f668cc8a2f7b7f.sample"
[deps]
source_file="res://assets/Audio/SFX/player_attak.wav"
dest_files=[ "res://.import/player_attak.wav-e4631e12f4d8c16946f668cc8a2f7b7f.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=false
compress/mode=0

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/spike_trap.wav-f53302c3ddefb0b0f57ad30678d3546b.sample"
[deps]
source_file="res://assets/Audio/SFX/spike_trap.wav"
dest_files=[ "res://.import/spike_trap.wav-f53302c3ddefb0b0f57ad30678d3546b.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=false
compress/mode=0

BIN
assets/Audio/SFX/spring.wav Normal file

Binary file not shown.

View file

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/spring.wav-a38a4871e911a90a2c3beb40a041ae50.sample"
[deps]
source_file="res://assets/Audio/SFX/spring.wav"
dest_files=[ "res://.import/spring.wav-a38a4871e911a90a2c3beb40a041ae50.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=false
compress/mode=0

View file

@ -13,6 +13,10 @@ export var wall_jump_speed_factor := Vector2(1 ,.8)
export var dash_thrust = 550.0
export var max_wall_slide_gravity := 100.0
const FLOOR_NORMAL := Vector2.UP
const SNAP_DIRECTION := Vector2.DOWN
const SNAP_LENGTH := 4.0
var LandingDust = load("res://src/Actors/LandingDust.tscn")
var JumpDust = load("res://src/Actors/JumpDust.tscn")
var LightBeam = load("res://src/Actors/LightBeam.tscn")
@ -29,6 +33,7 @@ var _can_dash := true
var _is_jump_canceled := false
var _direction := Vector2.ZERO
var _boost_velocity :Vector2 = Vector2.ZERO
var _snap_vector = SNAP_DIRECTION * SNAP_LENGTH
var _falling_start_position := .0
@ -64,7 +69,7 @@ func _physics_process(delta: float) -> void:
_input_check()
_velocity = calculate_move_velocity(_direction,_is_jump_canceled, delta)
_velocity = _boost_velocity if _boost_velocity != Vector2.ZERO else _velocity
_velocity = move_and_slide(_velocity, Vector2.UP)
_velocity = move_and_slide_with_snap(_velocity, _snap_vector if _direction.y != -1 else Vector2.ZERO, FLOOR_NORMAL)
_boost_velocity = Vector2.ZERO
_check_collisions()
update_sprite(_direction)
@ -98,7 +103,7 @@ func _update_state(new_state:int = -1):
if _state == States.DASHING: return
if _state == States.ATTACKING: return
if _state == States.IDLE:
if _velocity.y > 0 and not is_on_floor():
if (_velocity.y > 0 and not is_on_floor()) or _boost_velocity.y != 0:
# Falling from ground
new_state = States.IN_AIR
elif _state == States.IN_AIR:
@ -132,6 +137,9 @@ func _transition_state(old_state, new_state, auto_update):
if old_state == States.WALL_SLIDING:
if new_state == States.IDLE:
_on_landed()
# if old_state == States.IN_AIR:
# if new_state == States.IDLE:
# print("LANDED!@!!")
func _on_landed():
_can_dash = true

View file

@ -410,7 +410,7 @@ tracks/4/keys = {
"values": [ true ]
}
[sub_resource type="Animation" id=12]
[sub_resource type="Animation" id=9]
resource_name = "land"
length = 0.1
tracks/0/type = "value"
@ -474,7 +474,7 @@ tracks/4/keys = {
"values": [ true ]
}
[sub_resource type="Animation" id=9]
[sub_resource type="Animation" id=10]
length = 0.1
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:frame")
@ -537,7 +537,7 @@ tracks/4/keys = {
"values": [ true ]
}
[sub_resource type="Animation" id=10]
[sub_resource type="Animation" id=11]
length = 0.5
loop = true
tracks/0/type = "value"
@ -601,7 +601,7 @@ tracks/4/keys = {
"values": [ true ]
}
[sub_resource type="Animation" id=11]
[sub_resource type="Animation" id=12]
length = 0.3
loop = true
tracks/0/type = "value"
@ -715,10 +715,10 @@ anims/die = SubResource( 5 )
anims/fall = SubResource( 6 )
anims/idle = SubResource( 7 )
anims/jump = SubResource( 8 )
anims/land = SubResource( 12 )
anims/pre_jump = SubResource( 9 )
anims/run = SubResource( 10 )
anims/wall_slide = SubResource( 11 )
anims/land = SubResource( 9 )
anims/pre_jump = SubResource( 10 )
anims/run = SubResource( 11 )
anims/wall_slide = SubResource( 12 )
[node name="DashTimeout" type="Timer" parent="."]
wait_time = 0.12
@ -743,5 +743,6 @@ cast_to = Vector2( -5.2, 0 )
collision_mask = 8
[node name="Camera" parent="." instance=ExtResource( 4 )]
smoothing_enabled = false
[connection signal="body_entered" from="Sprite/SordRange" to="." method="_on_SordRange_body_entered"]
[connection signal="timeout" from="DashTimeout" to="." method="_on_DashTimeout_timeout"]

View file

@ -70,12 +70,20 @@ func _set_camera_limits():
func _set_player_position(is_entering:bool):
var warps = _get_all_warps()
var found_spawn_point := false
var position = Vector2.ZERO
for warp in warps:
if warp.to_level_coord == prev_level:
_player.position = warp.get_checkpoint_position()
_player.face_player(is_entering)
_player.respawn_position = _player.position
position = warp.get_checkpoint_position()
found_spawn_point = true
print("Found point warp.position.x = %s player spawn.x = %s" % [warp.position.x, _player.position.x])
if not found_spawn_point:
position = level_entry_point if is_entering else level_exit_point
_player.face_player(is_entering)
_player.respawn_position = position
_player.position = position
func _set_wrap_zones():
_first_time_init = false

View file

@ -270,6 +270,7 @@ to_level_coord = Vector2( 0, 1 )
[node name="SpikeTrap" parent="." instance=ExtResource( 16 )]
position = Vector2( 352, 208 )
direction = 1
[node name="Spring" parent="." instance=ExtResource( 17 )]
position = Vector2( 98, 240 )

View file

@ -12,6 +12,7 @@ func _on_DamageArea_body_entered(body: Node) -> void:
func _on_TriggerArea_body_entered(body: Node) -> void:
if body.name == "Player" and not triggerd:
AudioManager.play_sfx(AudioManager.Sfx.SPIKE_TRAP)
triggerd = true
$AnimationPlayer.play("emit")
yield($AnimationPlayer, "animation_finished")

View file

@ -5,5 +5,6 @@ export var thrust:float = 250
func _on_Area2D_body_entered(body: Node) -> void:
if body.name == "Player":
body.boost(Vector2(body._velocity.x, -thrust))
body.boost(Vector2(0, -thrust))
AudioManager.play_sfx(AudioManager.Sfx.SPRING)
$AnimationPlayer.play("activated")

View file

@ -29,7 +29,9 @@ enum Sfx{
PLAYER_ATTACK,
PLAYER_DIE,
UI_MOVE,
UI_SELECT
UI_SELECT,
SPRING,
SPIKE_TRAP
}
var _sfx_files := {
@ -39,6 +41,8 @@ var _sfx_files := {
Sfx.PLAYER_DASH : load("res://assets/Audio/SFX/player_dash.wav"),
Sfx.PLAYER_ATTACK : load("res://assets/Audio/SFX/player_attack.wav"),
Sfx.PLAYER_DIE : load("res://assets/Audio/SFX/player_die.wav"),
Sfx.SPRING : load("res://assets/Audio/SFX/spring.wav"),
Sfx.SPIKE_TRAP : load("res://assets/Audio/SFX/spike_trap.wav"),
Sfx.UI_MOVE : load("res://assets/Audio/UI_Sounds/menu_move_sound.wav"),
Sfx.UI_SELECT : '',
}