Creating simple dynamic objects.

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
span4ev
Regular
Posts: 105
Joined: Fri Jul 08, 2022 9:29 pm
itch: rpymc
Contact:

Creating simple dynamic objects.

#1 Post by span4ev »

Please help, I'm desperate.
How can I create a simple object (rectangle) that I can move with visible movement animation? I used RoundRect() but I couldn't get the movement animation.
I am not interested in ATL animation like "transform", animation of objects in "label" via "show at" and not interested in animation via "label" at all. I only want to move objects inside the "screen".

I'd like to figure out renpy.displayable, but I find it complicated. Can anyone give a minimal template for creating a rectangle via the renpy.displayable class that I can later move with animation? That is, it should be a class that I can use and create any number of rectangles. Just the simplest example that I can build off of in terms of learning how renpy.displayable works. Please.

Which is easier to learn: renpy.displayable or using pygame?
Which will work better: renpy.displayable or using pygame?

User avatar
m_from_space
Miko-Class Veteran
Posts: 886
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Creating simple dynamic objects.

#2 Post by m_from_space »

span4ev wrote: Sun Nov 26, 2023 9:34 amI am not interested in ATL animation like "transform", animation of objects in "label" via "show at" and not interested in animation via "label" at all. I only want to move objects inside the "screen".
I mean ATL transforms are really neat when it comes to moving and animating stuff, because you don't have to take care of timing or framerate, Renpy does it for you.

About that rectangle. If you don't want to use pygame or a creator-defined displayable, just create an area filled with a color and place another area inside that has padding. It's all about illusions, you know.

Code: Select all

screen rectangles():
    use myrect(100, 200, 300, 50)
    use myrect(500, 500, 600, 100)

screen myrect(x, y, w, h):
    frame:
        background Solid("#f00")
        padding (1, 1)
        pos (x, y)
        xysize (w, h)
        frame:
            background Solid("#000")
            xfill True yfill True

label start:
    show screen rectangles

User avatar
m_from_space
Miko-Class Veteran
Posts: 886
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Creating simple dynamic objects.

#3 Post by m_from_space »

If you want rectangles that are transparent, just do it like this, using the attached image (it's a 100x100 transparent PNG with a 1 pixel white border).

Code: Select all

screen rectangles():
    use myrect(100, 200, 300, 50)
    use myrect(500, 500, 600, 100)

screen myrect(x, y, w, h):
    frame:
        # using 2 or more instead of 1 makes sure we have no blurry lines
        background Frame("rectangle", 2, 2, 2, 2)
        pos (x, y)
        xysize (w, h)
Attachments
rectangle.png
rectangle.png (726 Bytes) Viewed 469 times

Post Reply

Who is online

Users browsing this forum: elcharlo