add dash limit
This commit is contained in:
parent
90ed572277
commit
c35ddb261a
|
@ -5,6 +5,7 @@ extends Area2D
|
|||
export var speed : float = 1
|
||||
export var speed_dash : float = 3
|
||||
export var rest : float = 1
|
||||
export var dashes : int = 1
|
||||
|
||||
export var tile_position := Vector2(0,0)
|
||||
export(NodePath) var level_tilemap
|
||||
|
@ -101,7 +102,7 @@ func _process(delta):
|
|||
update_position()
|
||||
last_move_time = OS.get_ticks_msec() / 1000.0
|
||||
|
||||
if Input.is_action_just_pressed("dash"):
|
||||
if dashes > 0 and Input.is_action_just_pressed("dash"):
|
||||
|
||||
if not current_target == null:
|
||||
tile_position = current_target
|
||||
|
@ -111,10 +112,11 @@ func _process(delta):
|
|||
movement_queue = [current_direction]
|
||||
current_target = Vector2 (dash_end.x, dash_end.y)
|
||||
dashing = true
|
||||
dashes = dashes - 1
|
||||
|
||||
func update_position():
|
||||
position = level.cell_custom_transform * (tile_position + Vector2.ONE / 2 )
|
||||
|
||||
func update_animation():
|
||||
sprite.animation = current_direction.animation
|
||||
sprite.frame = step_count % 2
|
||||
sprite.frame = step_count % 2 + (0 if dashes > 0 else 2)
|
||||
|
|
Loading…
Reference in New Issue