Dash dash baby

This commit is contained in:
Debugman committed 2026-10-17 12:21:33 -05:00
1 parent a73609b86b
commit 11e291e867
12 files changed
+222 -30

No files matched your search

+18 -3
View File
@@ -2,6 +2,7 @@ extends CharacterBody2D
const SPEED = 380.0
const DASH_SPEED = 600
const HORIZONTAL_DASH_MULT = 1.8
const FRICTION = 100
const GRAVITY_MULT = 0.8
@@ -20,8 +21,14 @@ var coins = 0
func _ready() -> void:
pass
func refresh_dash(new_dashes):
if new_dashes:
dashes = new_dashes
else:
dashes = 1
func refresh_jump(new_jumps):
if jumps:
if new_jumps:
jumps = new_jumps
else:
jumps = 1
@@ -53,13 +60,16 @@ func _process(delta: float) -> void:
if direction < 0:
$Sprite2D.flip_h = true
$Sprite2D/HatSprite.flip_h = true
elif direction > 0:
$Sprite2D.flip_h = false
$Sprite2D/HatSprite.flip_h = false
if Input.is_action_just_pressed("dash"):
if Input.is_action_just_pressed("dash") and dashes > 0:
dashing = true
dashes -= 1
velocity = Vector2(
Input.get_axis("dash_left","dash_right"),
Input.get_axis("dash_left","dash_right") * HORIZONTAL_DASH_MULT,
Input.get_axis("dash_up","dash_down")
) * DASH_SPEED
await get_tree().create_timer(DASH_LENGTH).timeout
@@ -68,10 +78,12 @@ func _process(delta: float) -> void:
elif direction and !dashing:
velocity.x = direction * SPEED
$Sprite2D.play("running")
$Sprite2D/HatSprite.play("running")
elif !dashing:
velocity.x = move_toward(velocity.x, 0, FRICTION)
$Sprite2D.play("idle")
$Sprite2D/HatSprite.play("idle")
#print("PLAYER X POSITION: " + str(position.y))
if position.y >= death_threshold:
@@ -82,14 +94,17 @@ func _process(delta: float) -> void:
if is_on_floor():
fall_timer = 0
refresh_jump(1)
refresh_dash(1)
#%Player2D.get_node("Camera2D").position_smoothing_speed = %Player2D.CAMERA_SMOOTHING_SPEED
if is_on_wall():
refresh_jump(1)
refresh_dash(1)
#%Player2D.get_node("Camera2D").position_smoothing_speed = %Player2D.CAMERA_SMOOTHING_SPEED
if is_on_ceiling():
refresh_jump(1)
refresh_dash(1)
if fall_timer > 3:
pass