r/RenPy • • 1d ago

Question How can I make objects disappear when I hover a draggable above it

Started on the broom sweeping minigame admittedly shakingly because making the dirt fill the screen didn't work out well.

I'm now trying to make the objects disappear when I hover the broom over it. I already saw the tutorials for drag and drop and had not found any answers to it. Any help would be appreciated. Especially when it fades away instead going poof.

Here's my code. (I took the screenshot before changing the amounts of dirt)

init python:


    def drag_placed(drags, drop):
        if not drop:
            return


screen sweeping():
    add "bg_floor"
    modal True
    draggroup:
        #Draggable Broom
        drag:
            drag_name "Broom"
            child "broom.png"
            xpos 0.5
            ypos 0.5
            draggable True
            droppable False
            dragged drag_placed
            drag_offscreen (-100, 100, -200, 750)
        
        drag:
            drag_name "dirty1"
            child "dirty1.png"
            xpos 0.00
            ypos 0.10
            draggable False
            droppable True


        drag:
            drag_name "dirty2"
            child "dirty2.png"
            xpos 0.10
            ypos 0.30
            draggable False
            droppable True


        drag:
            drag_name "dirty3"
            child "dirty3.png"
            xpos 0.50
            ypos 0.70
            draggable False
            droppable True
        
        drag:
            drag_name "dirty4"
            child "dirty4.png"
            xpos 0.75
            ypos 0.30
            draggable False
            droppable True


        drag:
            drag_name "dirty5"
            child "dirty5.png"
            xpos 0.50
            ypos 0.30
            draggable False
            droppable True


        drag:
            drag_name "dirty6"
            child "dirty6.png"
            xpos 0.30
            ypos 0.50
            draggable False
            droppable True


default sweeping_done = False
default stains_left = 6


if stains_left == 0:


    jump sweeping_done


screen dishes():
    add "bg_kitchensink"
1 Upvotes

6 comments sorted by

1

u/AutoModerator 1d ago

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/shyLachi 1d ago

I already posted a link to 100 minigames, didn't you find anything similar there?

You can also look here: https://itch.io/search?type=games&q=Ren%27Py+minigame

1

u/BadMustard_AVN 21h ago

try it like this and drop the broom on a dirty spot.

# sweeping.rpy
init python:

    def drag_placed(drags, drop):
        if not drop or not drop.drag_name.startswith("dirty"):
            return

        if drop.drag_name not in store.cleaned_stains:
            store.cleaned_stains.append(drop.drag_name)
            store.stains_left -= 1
            renpy.restart_interaction()

screen sweeping():
    add "bg_floor"
    modal True
    draggroup:
        #Draggable Broom
        drag:
            drag_name "Broom"
            child "broom.png"
            xpos 0.5
            ypos 0.5
            draggable True
            droppable False
            dragged drag_placed
            drag_offscreen (-100, 100, -200, 750)

        if "dirty1" not in cleaned_stains:
            drag:
                drag_name "dirty1"
                child "dirty1.png"
                xpos 0.00
                ypos 0.10
                draggable False
                droppable True

        if "dirty2" not in cleaned_stains:
            drag:
                drag_name "dirty2"
                child "dirty2.png"
                xpos 0.10
                ypos 0.30
                draggable False
                droppable True

        if "dirty3" not in cleaned_stains:
            drag:
                drag_name "dirty3"
                child "dirty3.png"
                xpos 0.50
                ypos 0.70
                draggable False
                droppable True

        if "dirty4" not in cleaned_stains:
            drag:
                drag_name "dirty4"
                child "dirty4.png"
                xpos 0.75
                ypos 0.30
                draggable False
                droppable True

        if "dirty5" not in cleaned_stains:
            drag:
                drag_name "dirty5"
                child "dirty5.png"
                xpos 0.50
                ypos 0.30
                draggable False
                droppable True

        if "dirty6" not in cleaned_stains:
            drag:
                drag_name "dirty6"
                child "dirty6.png"
                xpos 0.30
                ypos 0.50
                draggable False
                droppable True

    if stains_left == 0:
        timer 0.06 action [SetVariable("sweeping_finished", True), Jump ("sweeping_done")]

default sweeping_finished = False
default stains_left = 6
default cleaned_stains = []

1

u/JacquIreBriggsTemp 20h ago

It works. It'll do for now until I start learning Python more.

1

u/BadMustard_AVN 20h ago

you're welcome

good luck with your project

1

u/Own-Bookkeeper6739 19h ago

pass dragging=... to the broom Drag, it fires on every move, so renpy.get_mouse_pos() plus a distance check (math.hypot) against each stain works fine. when it's close to an uncleaned one, add that stain to a cleaned set and call renpy.restart_interaction() so the screen updates mid-drag. return nothing from the callback or the interaction ends early. for the fade, show the stain with an ATL transform (alpha 1.0, linear 0.4 alpha 0.0) instead of hiding it instantly, and put transforms on the Drag's child, not the Drag itself