added dash and start of tilesetting

This commit is contained in:
2021-11-21 23:00:07 -06:00
parent 436f2db61f
commit a06458b8a1
12 changed files with 406 additions and 7 deletions

View File

@@ -5,6 +5,8 @@ const MAX_SPEED = 120
const FRICTION = 1000
var velocity: Vector2 = Vector2.ZERO
var isDash = false
var counter = 0
func _physics_process(delta) -> void:
@@ -19,6 +21,21 @@ func _physics_process(delta) -> void:
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
else:
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
# if dashing, increase velocity by 4 for one frame
if Input.is_action_just_pressed("player_dash") and input_vector != Vector2.ZERO and isDash == false:
velocity = velocity * 4
isDash = true
# If the dash was previously pressed, start a counter
if isDash:
counter += 1
# wait time before you can dash again
if counter > 60:
counter = 0
isDash = false
velocity = move_and_slide(velocity)
return