The main menu and animation

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.
Message
Author
Helveds
Newbie
Posts: 8
Joined: Wed Mar 24, 2010 3:34 pm
Contact:

The main menu and animation

#1 Post by Helveds »

Hello there.

Currently, I am trying to put animation in my main menu over my image map. My current code is

Code: Select all

init -2 python:
    layout.imagemap_main_menu("main_menu.png", "main_menu2.png", [
        (0, 185, 145, 261, "Start Game"),
        (0, 269, 145, 345, "Load Game"),
        (0, 357, 178, 452, "Preferences"),
        (608,0,787,89, "Quit"),
        ])
To simplify things, I am using PyTom's example of animation with

Code: Select all

image ctc = anim.Filmstrip("sakura.png", (20, 20), (2, 1), .30,
                               xpos=760, ypos=560, xanchor=0, yanchor=0)
(I realize this does not make the animation all over the screen, which is another problem...)

I realize that I am putting the image outside of the init -2 python, but whenever I put it in the code for the main menu inside init -2 python, I get an error.

Let me give you an example of what I'm trying to do, to better clarify.

I want my game to load up with the appropriate image maps, which are working correctly right now. I also want a animation, say rain, to come down from the left or right side of the screen to the bottom. I need help making the appropriate code for image ctc and where to impliment it into the code.

I know I am asking a lot, but perhaps this would clarify it for a lot of people.

Thank you,
Helveds

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: The main menu and animation

#2 Post by Aleema »

I have something like this for one of my main menus. You'll have to rebuild the main menu and NOT use imagemaps. Imagemaps, in my experience, do not let anything overlap them, so you'll have to use buttons (either image or text). You'd build the main menu screen like you would any other label, and then link the buttons to the appropriate functions to start/quit/load/prefs. If you're willing to do that for your menu, then I can share the code I've got, but you have to know that I use imagebuttons for navigation, not imagemaps.

Otherwise, you'd have to make your full-screen imagemap for the main menu animated itself.

Helveds
Newbie
Posts: 8
Joined: Wed Mar 24, 2010 3:34 pm
Contact:

Re: The main menu and animation

#3 Post by Helveds »

Well, sure, since I don't really know all that much and I'm not really looking for an "uber professional" VN, I'll take what I can get. What's the code you use?

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: The main menu and animation

#4 Post by Aleema »

Take what you can get? Ouch. Well, despite my hurt pride, I will help you anyway. :cry:

You have to make a new label for your menu, called "label main_menu". You can set a background with "scene" or "show" just like any other label. You'll then need to code the buttons using UI functions. When they are clicked, have them jump to the following:

New Game --> "start", it's important that you have it "jump_out_of_context" rather than just jump, because this will screw everything up, trust me.
Load Game --> "load_screen"
Preferences --> "preferences_screen"
Quit --> $ renpy.quit()

You can then add whatever else you want to screen, like rain or blossoms.

Code in action:

Code: Select all

label main_menu:
    scene mainmenu

    $ ui.vbox(xpos=364, ypos=215)
    $ ui.imagebutton("newgame1.png", "newgame2.png", clicked=ui.returns("start"))
    $ ui.imagebutton("loadgame1.png", "loadgame2.png", clicked=ui.returns("load"))
    $ ui.imagebutton("options1.png", "options2.png", clicked=ui.returns("prefs"))
    $ ui.imagebutton("exit1.png", "exit2.png", clicked=ui.returns("quit"))
    $ ui.close()

    $ result = ui.interact()
    
    if result == "start":
        hide mainmenu
        $ renpy.jump_out_of_context("start")
    elif result == "load":
        jump load_screen
    elif result == "prefs":
        jump preferences_screen
    elif result == "quit":
        $ renpy.quit()

Sagakure
Newbie
Posts: 20
Joined: Sat Apr 17, 2010 8:04 pm
Projects: Untitled VN project: Still in its beginnings, but hopeful. :D
Contact:

Re: The main menu and animation

#5 Post by Sagakure »

Sorry to butt in on someone else's thread, but I just wanted to say: Thank you so much for sharing that wonderful code, Aleema!!

*grabs the code and runs off with it, is utterly delighted with how her menu looks like now* :D :D :D I needed exactly something like that, and it works so perfectly!!



If by any chance you felt like also sharing something like that on the subject of a little slide-down menu that players can call down by passing the mouse over the top area of the window, so that they can save or load etc. during gameplay, it would be absolutely wonderful too. :D :D :D If it's not a bother, of course!
Night ❤ Hall
http://www.sagakure.net/
Image

(My Vampire Knight fan site.)

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: The main menu and animation

#6 Post by Aleema »

Sagakure wrote:If by any chance you felt like also sharing something like that on the subject of a little slide-down menu that players can call down by passing the mouse over the top area of the window, so that they can save or load etc. during gameplay, it would be absolutely wonderful too. :D :D :D If it's not a bother, of course!
You're very welcome! Now, I haven't seen anything like what you're asking, but I take that as a challenge. ;)
I'll look into it, and if I come up with anything, I'll let you know!

Sagakure
Newbie
Posts: 20
Joined: Sat Apr 17, 2010 8:04 pm
Projects: Untitled VN project: Still in its beginnings, but hopeful. :D
Contact:

Re: The main menu and animation

#7 Post by Sagakure »

Awesome!! :D :D :D Thank you so much in advance, for considering it and all! *looks forward to what you might make of it*

Here's an example from another game, of the type of menu I mean, in case it wasn't very clear in the way I explained it:

The game looks normal like this when you're playing it:
Image

And if you happen to take your mouse cursor over to the very top area of the window, the menu then slides down to appear like this:
(I have my cursor over the load button.)
Image

In my epic noobness, I hadn't realized before that you could right-click in ren'py to access the normal menu, but the sliding down menu is prettier and might also be very good if any of the players fail at gaming as bad as me and doesn't realizes that either. 8D;;;

Again, thank you for considering it and for seeing what you can make of it. :D :D :D
Night ❤ Hall
http://www.sagakure.net/
Image

(My Vampire Knight fan site.)

Helveds
Newbie
Posts: 8
Joined: Wed Mar 24, 2010 3:34 pm
Contact:

Re: The main menu and animation

#8 Post by Helveds »

Aleema wrote:Take what you can get? Ouch. Well, despite my hurt pride, I will help you anyway. :cry:

You have to make a new label for your menu, called "label main_menu". You can set a background with "scene" or "show" just like any other label. You'll then need to code the buttons using UI functions. When they are clicked, have them jump to the following:

New Game --> "start", it's important that you have it "jump_out_of_context" rather than just jump, because this will screw everything up, trust me.
Load Game --> "load_screen"
Preferences --> "preferences_screen"
Quit --> $ renpy.quit()

You can then add whatever else you want to screen, like rain or blossoms.

Code in action:

Code: Select all

label main_menu:
    scene mainmenu

    $ ui.vbox(xpos=364, ypos=215)
    $ ui.imagebutton("newgame1.png", "newgame2.png", clicked=ui.returns("start"))
    $ ui.imagebutton("loadgame1.png", "loadgame2.png", clicked=ui.returns("load"))
    $ ui.imagebutton("options1.png", "options2.png", clicked=ui.returns("prefs"))
    $ ui.imagebutton("exit1.png", "exit2.png", clicked=ui.returns("quit"))
    $ ui.close()

    $ result = ui.interact()
    
    if result == "start":
        hide mainmenu
        $ renpy.jump_out_of_context("start")
    elif result == "load":
        jump load_screen
    elif result == "prefs":
        jump preferences_screen
    elif result == "quit":
        $ renpy.quit()
Oh, no, no, I was not meaning to sound rude. I really appreciate what you've done and shared. I apologize for anything offensive. I'm using that code now, and everything is working perfectly. Thank you very much :)

vaanknight
Regular
Posts: 118
Joined: Sun Mar 28, 2010 6:01 pm
Completed: Happy Weird-Day! How a freckled fairy can save your world (Or get more freckles in the process...)"
Projects: Nameless 2D Fighting Game
Contact:

Re: The main menu and animation

#9 Post by vaanknight »

whoa, as always Aleema marvels us with her witty self. I might as well make use of that code if I'm alolowed to. Thanks a bunch!

Also, pardon my noobness, I can edit that to customize the game menu and save/load screens too ne? How would be a code for those? What would be necesary to change? other than the images and positions, of course.
Image

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: The main menu and animation

#10 Post by Aleema »

vaanknight wrote:whoa, as always Aleema marvels us with her witty self. I might as well make use of that code if I'm alolowed to. Thanks a bunch!
Wakka, wakka! :wink:
Also, pardon my noobness, I can edit that to customize the game menu and save/load screens too ne? How would be a code for those? What would be necesary to change? other than the images and positions, of course.
Rebuilding the in-game menu and save/load screens from the ground up is something I've yet to do, so I wouldn't recommend it to a self-proclaimed "noob". It would be best to use the imagemap layouts to change their looks. I suppose you can create a new thread to find someone who has done that, because I would be interested myself. :)

alberte
Veteran
Posts: 204
Joined: Mon Dec 21, 2009 8:53 pm
Tumblr: klaruga
Deviantart: Klaruga
Location: Canada
Contact:

Re: The main menu and animation

#11 Post by alberte »

Awesome code Aleema!
(X
now to try to make use of it :P

vaanknight
Regular
Posts: 118
Joined: Sun Mar 28, 2010 6:01 pm
Completed: Happy Weird-Day! How a freckled fairy can save your world (Or get more freckles in the process...)"
Projects: Nameless 2D Fighting Game
Contact:

Re: The main menu and animation

#12 Post by vaanknight »

Oh, I tried my hand at imagemaps and it didn't go well. xD I think I will open that thread, yes. Maybe someone can share a code that's proven to work.
Image

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: The main menu and animation

#13 Post by Aleema »

alberte wrote:Awesome code Aleema!
(X
now to try to make use of it
Holy cow. Didn't realize so many people wanted this code? I'll put it on the FAQs or something ...
vaanknight wrote:Oh, I tried my hand at imagemaps and it didn't go well. xD I think I will open that thread, yes. Maybe someone can share a code that's proven to work.
:( You honestly should get the imagemaps to work rather than try to rebuild absolutely everything. If you need help with the imagemaps, I can help you. Trust me, once you get a hang of it, it's so great. (And easier.)>_>

vaanknight
Regular
Posts: 118
Joined: Sun Mar 28, 2010 6:01 pm
Completed: Happy Weird-Day! How a freckled fairy can save your world (Or get more freckles in the process...)"
Projects: Nameless 2D Fighting Game
Contact:

Re: The main menu and animation

#14 Post by vaanknight »

I just did learn all about it, thanks to mugen's help in the other thread I opened I am now able to make any and every imagemap that comes to my mind by myself! :D All I needed was a working example. I'm about to burst into tears due to extreme gratefulness to all of ye.
Image

User avatar
nash
Newbie
Posts: 20
Joined: Sat Jan 29, 2011 4:23 pm
Contact:

Re: The main menu and animation

#15 Post by nash »

Aleema wrote:I have something like this for one of my main menus. You'll have to rebuild the main menu and NOT use imagemaps. Imagemaps, in my experience, do not let anything overlap them, so you'll have to use buttons (either image or text). You'd build the main menu screen like you would any other label, and then link the buttons to the appropriate functions to start/quit/load/prefs. If you're willing to do that for your menu, then I can share the code I've got, but you have to know that I use imagebuttons for navigation, not imagemaps.

Otherwise, you'd have to make your full-screen imagemap for the main menu animated itself.
Unfortunately, this is my problem. I wanna a Cherry-Blossom rain. It work's with $ ui.imagebutton but I also use imagemap for my main-menu. How can I realize it with imagemaps, also in the screen.rpy, cause I can't call script-functions there >_<
1 Litre of Tears
Image

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot]