Random Main Menu Background

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
clannadman

Random Main Menu Background

#1 Post by clannadman »

I've tried myself and failed with this. I'm trying to implement it so the main menu background is randomly chosen each time out of several. Any idea how to do this in screens?

User avatar
chewpower
Regular
Posts: 36
Joined: Mon Feb 11, 2013 11:08 pm
Contact:

Re: Random Main Menu Background

#2 Post by chewpower »

How do you implement the main menu background in screens? Something with imagemap?

If so, just an idea, store the ground, idle, hover images in variables with fixed initial values.

Code: Select all

screen main_menu:
    $ grounds = "map_ground.jpg"
    $ hovers = "map_hover.jpg"
Then pick a random number from 1 to as many as the available background images, say 5.

Code: Select all

$ random = renpy.random.randint(1,5)
Then change the grounds and hovers according to the result

Code: Select all

    if(random == 2):
        $ grounds = "map2_ground.jpg"
        $ hovers = "map2_hover.jpg"
    elif(random == 3):
        $ grounds = "map3_ground.jpg"
        $ hovers = "map3_hover.jpg"
    elif(random == 4):
        $ grounds = "map4_ground.jpg"
        $ hovers = "map4_hover.jpg"        
    elif(random == 5):
        $ grounds = "map5_ground.jpg"
        $ hovers = "map5_hover.jpg"      
In the imagemap part, the ground and hover image are declared like so

Code: Select all

imagemap:
    ground grounds
    hover hovers

    # hotspots...
Something like this?
I'm sorry if I'm too stupid, but I can't learn to walk on my own

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], eleloyce, Google [Bot]