20 lines
695 B
GDScript
20 lines
695 B
GDScript
extends CharacterBody2D
|
|
|
|
const SPEED = 3.0
|
|
func _ready() -> void:
|
|
await get_tree().process_frame
|
|
var crystals = get_tree().get_nodes_in_group("crystals")
|
|
print("Got " + str(crystals.size()) + " crystals")
|
|
for crystal in crystals:
|
|
print("Connecting crystal: " + crystal.name)
|
|
crystal.connect("crystal_picked_up", Callable(self, "collect"))
|
|
|
|
func collect():
|
|
print("something")
|
|
|
|
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)
|