-
Notifications
You must be signed in to change notification settings - Fork 0
Making a custom droplet
kyfex edited this page Feb 4, 2026
·
4 revisions
In Ultrapool, droplets are little objects on the board that can be hit with a pool ball. Think flowers or oil :3
Making droplets is significantly different from other objects in Ultrapool. To create a droplet, call CUE.register_droplet() with the following parameters:
-
init: A callable that runs when the droplet is initialized. It takes one parameter: the droplet itself. -
on_ball: A callable that runs when a ball hits this droplet. It takes two parameters: itself and the ball that hit it. -
process: A callable that runs every frame. It takes two parameters: itself and the time that's passed since this function ran last. -
remove: A callable that runs when the droplet is removed from the scene. It takes one parameter: itself.
This function returns an integer. Store this in a global variable somewhere; this is how you can tell if any given droplet is your custom droplet.
Your code should look something like this:
var my_custom_type = CUE.register_droplet(func(droplet:Droplet):
# Initialize stuff here
pass, func(droplet:Droplet, ball:Ball):
# Collision stuff here
pass, func(droplet:Droplet, delta:float):
# Process stuff here
pass, func(droplet:Droplet):
# Remove stuff here
pass)When working with this droplet, here are some things to keep in mind.
- To spawn a droplet, you'll want code that looks something like this:
var droplet = load("res://effects/droplet.tscn").instantiate()
Global.gameManager.add_child(droplet)
droplet.global_position = Global.gameManager.get_random_free_position()
droplet.set_type(my_custom_type)
Global.gameManager.droplets.append(droplet)- To remove a droplet, make sure to call
droplet.remove(); don't justqueue_free()it. - To check if a droplet is your custom droplet, check if
droplet.droplet_typematchesmy_custom_type(your integer returned from registering the droplet.)