Crystalline-awakening/player/smallPlayer/playerScript.gd

20 lines
695 B
GDScript3
Raw Normal View History

2025-05-18 12:59:58 +00:00
extends CharacterBody2D
const SPEED = 3.0
2025-05-18 13:40:05 +00:00
func _ready() -> void:
2025-05-18 13:55:49 +00:00
await get_tree().process_frame
2025-05-18 13:40:05 +00:00
var crystals = get_tree().get_nodes_in_group("crystals")
2025-05-18 13:55:49 +00:00
print("Got " + str(crystals.size()) + " crystals")
2025-05-18 13:40:05 +00:00
for crystal in crystals:
2025-05-18 13:55:49 +00:00
print("Connecting crystal: " + crystal.name)
crystal.connect("crystal_picked_up", Callable(self, "collect"))
2025-05-18 12:59:58 +00:00
2025-05-18 13:40:05 +00:00
func collect():
print("something")
2025-05-18 12:59:58 +00:00
func _physics_process(delta: float) -> void:
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_vector("moveLeft", "moveRight", "moveUp", "moveDown")
move_and_collide(direction * SPEED)