Animated main/game menus

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
Criptych

Animated main/game menus

#1 Post by Criptych » Fri Jun 22, 2007 5:42 pm

I've seen in "Ori, Ochi, Onoe" that the main and game menus are animated when you enter them. But since the script is obfuscated, I can't figure out how you did that, and it's been bugging me. I've tried e.g. adding a MoveTransition containing the widget instead of the adding the widget directly, but all I get is an error. (Actually, it mentions a "curry" class. Is that related to what I'm doing wrong?)

On a related note, is there a way to get a list of files in an RPA, instead of just extracting the one(s) you want; or is that part of the obfuscation?

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

#2 Post by DaFool » Sat Jun 23, 2007 9:19 am

O3 was a custom script... so other than using LiveComposites, I'm not really sure how you would do animated menus otherwise.

User avatar
Criptych
Regular
Posts: 87
Joined: Sat Jun 23, 2007 9:19 am
Projects: ALICE.NET
Location: The other end of the internet.
Contact:

#3 Post by Criptych » Sat Jun 23, 2007 10:21 am

other than using LiveComposites, I'm not really sure how you would do animated menus
Ouch. :( Well, thanks. Guess I've got some reading to do.

P.S. Some pretty darn innovative stuff in MagiBou too. :D
Computers are useless. They can only give you answers. —Pablo Picasso

Image

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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:

#4 Post by PyTom » Sat Jun 23, 2007 12:27 pm

Here's the modern code for how to declare the O3 style spinning transitions.

Code: Select all

        def speedup(x):
            return x * x

        def slowdown(x):
            return 1.0 - (1.0 - x) ** 2
        
        def ignore_entering(pos, delay, d):
            return None
        
        revolvein = MoveTransition(0.5, enter_factory=RevolveInOut(-90, 0, time_warp=slowdown))
        revolveout = MoveTransition(0.5, leave_factory=RevolveInOut(0, 90, time_warp=speedup), enter_factory=ignore_entering)

        spinfadein = ComposeTransition(dissolve, after=revolvein)
        spinfadeout = ComposeTransition(dissolve, before=revolveout)
        spinfadeboth = ComposeTransition(dissolve, before=revolveout, after=revolvein)
Note that it only really works if the various components of the menu screen are positioned absolutely, at the top level of the game. So you'll need to place the buttons using config.main_menu_positions and config.game_menu_positions for this to stand a chance of working.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#5 Post by monele » Sat Jun 23, 2007 1:08 pm

And where would you tell the engine to use these transitions for the menus ? ô_o

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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:

#6 Post by PyTom » Sat Jun 23, 2007 1:15 pm

Um... config.enter_transition, config.main_game_transition, and the various other config.*_transition variables.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Criptych
Regular
Posts: 87
Joined: Sat Jun 23, 2007 9:19 am
Projects: ALICE.NET
Location: The other end of the internet.
Contact:

#7 Post by Criptych » Sat Jun 23, 2007 2:47 pm

You make it look so easy!!! XD

The same technique could be used for any transition, then? I'd like to have, say, each button drop from behind the one above it.

Code: Select all


def drop_button(pos,delay,d):
    start=pos
    start.yposition-=d.height
    return Move(start,pos,delay,child=d)

config.some_transition = MoveTransition(0.5, enter_factory=drop_button)
Would something like that work? Except, looking at the source, I don't think widgets can actually tell you their height...
Computers are useless. They can only give you answers. —Pablo Picasso

Image

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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:

#8 Post by PyTom » Sat Jun 23, 2007 3:44 pm

IIRC, there's a flag to Motion that makes it tell the function that computes the move it's height. I think your code is a bit wrong... IIRC, pos is a tuple, not an object.

But fundamentally, MoveTransition can be used to make all sorts of interesting effects.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Criptych
Regular
Posts: 87
Joined: Sat Jun 23, 2007 9:19 am
Projects: ALICE.NET
Location: The other end of the internet.
Contact:

#9 Post by Criptych » Sat Jun 23, 2007 4:20 pm

After a few trials (and errors), I've ended up with the following code:

Code: Select all

init python:
    def drop_button(pos,delay,d):
        start=Position(pos[0],0.0)
        return MoveTransition(start,pos,delay,child=d)
#...
    config.end_splash_transition = MoveTransition(0.5, enter_factory=drop_button)
But I receive this error message:

Code: Select all

  File "C:\...\RenPy\renpy\display\core.py", line 208, in visit_all
  File "C:\...\RenPy\renpy\display\core.py", line 1347, in <lambda>
AttributeError: 'Curry' object has no attribute 'per_interact'
I understand what the Curry does, but where is it coming from? Does this mean I need to "un-curry" something?

Thanks for all your help, everyone.
Computers are useless. They can only give you answers. —Pablo Picasso

Image

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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:

#10 Post by PyTom » Sat Jun 23, 2007 4:31 pm

Um.... you certainly should not be using a MoveTransition in the drop_button function. You'd want to use a Move, instead. I also think that the Position object is wrong... you want to simply use a tuple that gives the position.

(Hm... reading the wiki, this is unclear, so I fixed it.)

I'd write drop_button as:

Code: Select all

def drop_button(pos, delay, d, **kwargs):
    start = (0, pos[1], pos[2], pos[3])
    return Move(start, pos, delay)(d)
That's roughly equivalent to MoveIn, BTW.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Criptych
Regular
Posts: 87
Joined: Sat Jun 23, 2007 9:19 am
Projects: ALICE.NET
Location: The other end of the internet.
Contact:

#11 Post by Criptych » Sat Jun 23, 2007 5:24 pm

PyTom wrote:You'd want to use a Move, instead.
Duly noted, also changed Position -> tuple.
PyTom wrote:

Code: Select all

return Move(start, pos, delay)(d)
So it was a matter of un-currying...

Now I have

Code: Select all

def drop_button(pos,delay,d):
    start=(pos[0],0.0,pos[2],pos[3])
    return MoveIn(start,pos,delay)(d)
Which works fine, except that it seems to move everything at once. I'll probably have to play with timebases to change that, yes?
Computers are useless. They can only give you answers. —Pablo Picasso

Image

User avatar
Criptych
Regular
Posts: 87
Joined: Sat Jun 23, 2007 9:19 am
Projects: ALICE.NET
Location: The other end of the internet.
Contact:

#12 Post by Criptych » Sat Jun 23, 2007 10:20 pm

I've changed the design a little (mostly aesthetic) and now have:

Code: Select all

        def enter_button(pos,delay,d):
            start=(pos[0],1.0,pos[2],0.0)
            return MoveIn(start,pos,delay)(d)
        def leave_button(pos,delay,d):
            end=(pos[0],1.0,pos[2],0.0)
            return MoveOut(end,pos,delay)(d)
            
        slide_button_out =MoveTransition(0.5, leave_factory=leave_button)
        slide_button_in  =MoveTransition(0.5, enter_factory=enter_button)
        slide_button_both=MoveTransition(0.5, leave_factory=leave_button, enter_factory=enter_button)

# ...

        config.enter_transition = slide_button_in
        config.exit_transition = slide_button_out
        config.intra_transition = slide_button_both
        config.main_game_transition = slide_button_both
        config.game_main_transition = slide_button_both
        config.end_splash_transition = slide_button_in
        config.end_game_transition = slide_button_in
All the transitions are working fine (if a little slow on my computer) except the transition from main menu to game menu (main_game_transition); it just displays the menu immediately with no transition, while the rest have no problems. Any ideas why this is?
Computers are useless. They can only give you answers. —Pablo Picasso

Image

Post Reply

Who is online

Users browsing this forum: _ticlock_