2026-02-14 18:01:27 -05:00
|
|
|
extends CharacterBody2D
|
2026-02-10 18:29:46 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready() -> void:
|
2026-02-14 18:01:27 -05:00
|
|
|
$FishTux.play('stand')
|
2026-02-10 18:29:46 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
2026-02-14 18:01:27 -05:00
|
|
|
func _process(delta: float):
|
|
|
|
|
var velocity = Vector2.ZERO
|
|
|
|
|
var speed = 301
|
|
|
|
|
velocity.x += 0
|
2026-02-10 18:29:46 -05:00
|
|
|
|
2026-02-14 18:01:27 -05:00
|
|
|
if velocity.x > 0:
|
|
|
|
|
velocity = velocity.normalized() * speed
|
|
|
|
|
if speed > 300:
|
|
|
|
|
$FishTux.play('run')
|
|
|
|
|
$FishTux.scale.x = 1
|
|
|
|
|
else:
|
|
|
|
|
$FishTux.play('walk')
|
|
|
|
|
$FishTux.scale.x = 1
|
|
|
|
|
elif velocity.x < 0:
|
|
|
|
|
velocity = velocity.normalized() * speed
|
|
|
|
|
if speed > 300:
|
|
|
|
|
$FishTux.play('run')
|
|
|
|
|
$FishTux.scale.x = -1
|
|
|
|
|
else:
|
|
|
|
|
$FishTux.play('walk')
|
|
|
|
|
$FishTux.scale.x = -1
|
|
|
|
|
else:
|
|
|
|
|
$FishTux.play('stand')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
position += velocity * delta
|
|
|
|
|
position = position.clamp(Vector2.ZERO, get_viewport_rect().size)
|
2026-02-10 18:29:46 -05:00
|
|
|
|