Devlog Day 17: Godot random items

Godot looting continued
gamedev
godot
Author

Evan Lesmez

Published

August 18, 2024

Godot looting

Got a little further today.
Repeated setting up the Area2D pattern for handling the on_area_entered signal.
The next step in the project was to randomly generate loot.
This required a base Node2D with a child Timer node.
The timer node was needed to emit timeout signals at regular intervals to trigger item spawns.
get_node("Timer").timeout.connect(_on_timer_timeout)

Then to handle the timeout:

func _on_timer_timeout() -> void:
    var random_item_scene: PackedScene = item_scenes.pick_random()
    var item_instance := random_item_scene.instantiate()
    add_child(item_instance)

It looks a little goofy since I still haven’t removed the hardcoded behavior of queue_free on area entered for items.

Alternating gem and health pack spawning and destroying each other

Random aside, faillock is handy for when you mess up your sudo password a few times in a row and got locked out.

faillock --user {user-who-inted-away-password-attemps} # list your failed attemps
faillock --user {user-who-trolled} --reset # resets your lock so you can try again

Thanks for reading!