Files
tux-typing-plus/scenes/game/fish_tux.gd
2026-02-14 18:01:27 -05:00

38 lines
823 B
GDScript

extends CharacterBody2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$FishTux.play('stand')
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float):
var velocity = Vector2.ZERO
var speed = 301
velocity.x += 0
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)