added dash and start of tilesetting
This commit is contained in:
17
Player.gd
17
Player.gd
@@ -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
|
||||
|
Reference in New Issue
Block a user