Topic was automatically imported from the old Question2Answer platform.
Asked By
InkRobert
I need to implement a queue for my game “tower defense” genre, and I want to do it with the queue, but apparently in godot engine 4 just does not exist “queue”, because I could not find information about it
Isn’t an array already a queue, if you use pop_front() and push_back()?
var queue = []
var max_queue_size = 10
# Add an item to the queue if it has not reached its maximum capacity
func add_to_queue(item):
if len(queue) < max_queue_size:
queue.push_back(item)
# Removes the front item from the queue and returns whether or not the queue was empty
func finish_queue_front():
return bool(queue.pop_front())