You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

35 lines
875 B

extends Node
class_name PlayerDash
var keymap
const speed_scale = 2.5
const animation_name = "dash"
func ready(actor):
var ak = AttackKey.new()
keymap = { KEY_Z: ak.register(actor) }
func input(actor):
actor.show()
pass
func process(actor):
actor.get_animated_sprite().animation = animation_name
actor.get_animated_sprite().speed_scale = speed_scale
actor.get_animated_sprite().flip_h = actor.velocity.x < 0
func physics_process(actor, delta):
var velocity = actor.velocity
velocity = velocity.normalized() * actor.speed
if velocity.length() > 0:
actor.get_animated_sprite().play()
var collision = actor.move_and_collide(velocity * delta)
if collision:
collision.collider.on_collide(actor)
func sprite_finished(actor):
actor.state = actor.PlayerState.STANDING
actor.get_animated_sprite().flip_h = false
actor.get_animated_sprite().speed_scale = 1