Ability to dash from wall slide

This commit is contained in:
Sagi Dayan 2020-09-18 15:48:52 -04:00
parent 9bdaef2d86
commit 97fcc5fef4
2 changed files with 37 additions and 32 deletions

View file

@ -105,14 +105,19 @@ func calculate_move_velocity(direction:Vector2, is_jump_canceled:bool, delta:fl
0
)
if Input.is_action_just_pressed("dash") and _can_dash and !_is_wall_sliding:
output = dash_velocity
if Input.is_action_just_pressed("dash") and _can_dash:
_can_dash = false
_is_dashing = true # turn off gravity while dashing
# Wall dash first
if _is_wall_sliding:
dash_velocity.x = (-1 if _is_next_to_wall_right() else 1) * dash_thrust
if dash_velocity.x < 0 :
$DashParticlesLeft.emitting = true;
else:
$DashParticlesRight.emitting = true
output = dash_velocity
$DashTimeout.start()
return output;
@ -139,7 +144,7 @@ func _is_next_to_wall_left():
return colider.name == "SolidsTileMap"
return false
func update_sprite(direction:Vector2)->void:
func update_sprite(_direction:Vector2) -> void:
var air_animation = "jump" if _velocity.y <= 0 else "fall"
if _velocity.x > .5 and not _is_wall_sliding:
$AnimationPlayer.play("run" if is_on_floor() else air_animation)
@ -158,8 +163,8 @@ func update_sprite(direction:Vector2)->void:
return
if _is_dashing:
return
$AnimationPlayer.play("jump")
return
func _on_die_animation_done():
emit_signal("died")

File diff suppressed because one or more lines are too long