Question: Any draw module? [Solved]

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
Unin
Regular
Posts: 54
Joined: Wed Sep 01, 2010 8:08 pm
Location: Florida
Contact:

Question: Any draw module? [Solved]

#1 Post by Unin »

I'm looking to overlay basic shapes over a scene, mainly lines and polygons, but need to be able to manipulate them in-scene. I understand this could probably be accomplished with just semi-transparent overlay images, but I'm looking more for that retro heavily-aliased feeling of early 90s games. Is there any way to draw basic vectors over a scene, and change them based on coords?

I know I could probably do it in Pygame, but will I be able to overlay that over a Ren'Py scene, and manipulate it as the scene progresses (would this necessitate a re-render for each change?). Ideally, I'd like to be able animate mid-text/line, but I understand that's probably unfeasible.
Last edited by Unin on Sat Mar 30, 2013 6:34 pm, edited 3 times in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Question: Any draw module?

#2 Post by PyTom »

You can do this.

You need to create a Creator-Defined Displayable, and then call the canvas method of a render to get the render object.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Unin
Regular
Posts: 54
Joined: Wed Sep 01, 2010 8:08 pm
Location: Florida
Contact:

Re: Question: Any draw module?

#3 Post by Unin »

awesome, and canvas is just pygame.draw sans surfaces?

edit: found the udd page. thanks a ton. dynamic heads-up-display, here I come. :o

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Question: Any draw module?

#4 Post by PyTom »

Unin wrote:awesome, and canvas is just pygame.draw sans surfaces?
That's exactly what it is. Internally, it makes a surface, and draws to it using the pygame.draw functions. (It also sets up code that turns that surface into a GL texture, and adds that texture to a render.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Unin
Regular
Posts: 54
Joined: Wed Sep 01, 2010 8:08 pm
Location: Florida
Contact:

Re: Question: Any draw module? (Resolved)

#5 Post by Unin »

Wonderful. Is there any way I can add text to the render such that I don't have to manipulate text and my custom expression as 2 separate displayables?

I have a render I made scroll with crop, and want text to scroll with it, however changing the text changes the size of the width of the text displayable, which alters the rate it scales, making a huge heading in terms of alignment. If I could have my text on the same surface as the render, I could align it once and then crop as needed... That or find a way to get text with minwidth to play nice with crop
Attachments
script.rpy
w.i.p. HUD (updated)
(17.63 KiB) Downloaded 35 times

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Question: Any draw module? [mostly solved]

#6 Post by PyTom »

Yes.

Code: Select all

class MyDD(renpy.Displayable):
    def __init__(self):
        self.text = Text("Hello, World")

    def render(self, width, height, st, at):
        
        rv = renpy.Render(width, height)

        # Draw the text.
        text_render = renpy.render(self.text, width, height, st, at)
        rv.blit(text_render, (0, 0))
        
        canvas = rv.canvas()
        
        # ...
        
        return rv
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Unin
Regular
Posts: 54
Joined: Wed Sep 01, 2010 8:08 pm
Location: Florida
Contact:

Re: Question: Any draw module? [Solved]

#7 Post by Unin »

Ah, I hadn't tried in the init.That makes sense now. Does that mean all text needs to be hard coded into the class, or is there some way to pass a string into it? can I get away with calling a global string?


Thanks for all your help by the way. Hope I'm not drifting too far outside the scope of the question.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Question: Any draw module? [Solved]

#8 Post by PyTom »

You can pass in strings using normal Python parameter passing.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], MisterPinetree