added flipping of idle sprite anim and added flipping of actionable detector based on left or right facing

This commit is contained in:
eggman20339 2024-09-10 15:24:43 -04:00
parent 55a291e2ae
commit 12bce947f6

View File

@ -7,6 +7,8 @@ const MIN_JUMP_DURATION = 0.01
const GRAVITY = 980 const GRAVITY = 980
const FALL_GRAVITY_MULTIPLIER = 2 const FALL_GRAVITY_MULTIPLIER = 2
var isFacingRight: bool
var jump_timer = 0.0 var jump_timer = 0.0
var is_jumping = false var is_jumping = false
@ -36,6 +38,19 @@ func _physics_process(delta):
# Handle horizontal movement # Handle horizontal movement
var direction = Input.get_axis("move_left", "move_right") var direction = Input.get_axis("move_left", "move_right")
if direction < 0:
isFacingRight = false
elif direction > 0:
isFacingRight = true
if isFacingRight:
$Marker2D.scale.x = 1
$AnimatedSprite2D.scale.x = 1 * 0.2
else:
$Marker2D.scale.x = -1
$AnimatedSprite2D.scale.x = -1 * 0.2
if direction: if direction:
velocity.x = direction * SPEED velocity.x = direction * SPEED
else: else: