Compare commits

..

2 commits

View file

@ -41,9 +41,11 @@ const MIN_LAND_SPEED_FOR_SPLAT = 60.0
const LAND_PITCH_MIN = 0.87 const LAND_PITCH_MIN = 0.87
const LAND_PITCH_MAX = 1.15 const LAND_PITCH_MAX = 1.15
# ---- State ---- ###############
## Variables ##
###############
var isStickingToWall := false var isStickingToWall := false
var wallNormalX := 0.0 # -1 if the wall faces left, 1 if it faces right. var wallNormalX := 0.0
var isStickingToCeiling := false var isStickingToCeiling := false
var timeSpentUnstickingWall := 0.0 var timeSpentUnstickingWall := 0.0
@ -71,9 +73,9 @@ var wrapArcStartAngle := 0.0 # Angle around the corner where the arc begins.
var wrapSpeed := 0.0 var wrapSpeed := 0.0
var wrapDistanceTravelled := 0.0 var wrapDistanceTravelled := 0.0
###########
# ---- Nodes ---- ## Nodes ##
###########
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D @onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
@onready var collisionShape: CollisionShape2D = $CollisionShape2D @onready var collisionShape: CollisionShape2D = $CollisionShape2D
# Edge-finding raycasts, one each side, under a pivot we turn to face the surface we're on. # Edge-finding raycasts, one each side, under a pivot we turn to face the surface we're on.
@ -110,7 +112,7 @@ func _physics_process(delta: float) -> void:
_update_wrap(delta) _update_wrap(delta)
return return
var wasInAir := _get_surface_normal() == Vector2.ZERO var wasInAir := (_get_surface_normal() == Vector2.ZERO)
if not wasInAir: if not wasInAir:
isHoppingAcross = false isHoppingAcross = false
@ -128,7 +130,7 @@ func _physics_process(delta: float) -> void:
_update_horizontal_movement(delta, xInput, yInput) _update_horizontal_movement(delta, xInput, yInput)
_hold_at_edge(delta) _hold_at_edge(delta)
var wasOnWall := isStickingToWall and not is_on_floor() var wasOnWall := (isStickingToWall and not is_on_floor())
var velocityBeforeMove := velocity var velocityBeforeMove := velocity
move_and_slide() move_and_slide()
@ -167,13 +169,10 @@ func _update_facing(xInput: float, yInput: float) -> void:
if isStickingToCeiling: if isStickingToCeiling:
sprite.flip_h = xInput > 0 # Upside down, so flipped the other way. sprite.flip_h = xInput > 0 # Upside down, so flipped the other way.
elif isStickingToWall: elif isStickingToWall:
if wallNormalX < 0: if wallNormalX < 0: sprite.flip_h = yInput < 0
sprite.flip_h = yInput < 0 else: sprite.flip_h = yInput > 0
else:
sprite.flip_h = yInput > 0
else: else:
sprite.flip_h = xInput < 0 sprite.flip_h = xInput < 0
func _update_animation(xInput:float, yInput:float): func _update_animation(xInput:float, yInput:float):
if xInput and (isStickingToCeiling or is_on_floor()): if xInput and (isStickingToCeiling or is_on_floor()):