feat(val-blog): add 2026-04-30 dream journey post
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
extends Node
|
||||
|
||||
enum State { IDLE, WALKING, INTERACTING, ANIMATING }
|
||||
var current_state: State = State.IDLE
|
||||
|
||||
var target_position: Vector2 = Vector2.ZERO
|
||||
var move_speed: float = 100.0
|
||||
var is_moving: bool = false
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
match current_state:
|
||||
State.IDLE:
|
||||
pass
|
||||
State.WALKING:
|
||||
walk_towards_target(delta)
|
||||
State.INTERACTING:
|
||||
pass
|
||||
State.ANIMATING:
|
||||
pass
|
||||
|
||||
func set_state(new_state: State):
|
||||
current_state = new_state
|
||||
match new_state:
|
||||
State.IDLE:
|
||||
pass
|
||||
State.WALKING:
|
||||
start_walking()
|
||||
State.INTERACTING:
|
||||
start_interacting()
|
||||
State.ANIMATING:
|
||||
start_animating()
|
||||
|
||||
func start_walking():
|
||||
is_moving = true
|
||||
|
||||
func walk_towards_target(delta):
|
||||
if not is_moving:
|
||||
return
|
||||
var direction = (target_position - position).normalized()
|
||||
position += direction * move_speed * delta
|
||||
if position.distance_to(target_position) < 5.0:
|
||||
position = target_position
|
||||
is_moving = false
|
||||
set_state(State.IDLE)
|
||||
|
||||
func start_interacting():
|
||||
# Trigger interaction animation or logic
|
||||
pass
|
||||
|
||||
func start_animating():
|
||||
# Handle any animations
|
||||
pass
|
||||
|
||||
func move_to(pos: Vector2):
|
||||
target_position = pos
|
||||
set_state(State.WALKING)
|
||||
Reference in New Issue
Block a user