create a secret scene

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
viper
Newbie
Posts: 11
Joined: Mon Jan 21, 2019 4:47 pm
Projects: galaxy
Contact:

create a secret scene

#1 Post by viper »

hi, by advance sorry for my bad english i'm french.
i am the developer of a game called "Galaxy"
i'm new in renpy and i would like to hide a secret scene if the player click on a place in background.
but i would like that if is not clicked the story continue on another background is it possible?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: create a secret scene

#2 Post by Imperf3kt »

Sure.
You just need a screen with modal False (should be False by default)

In your screen, place an imagebutton and have it unlock your secret scene.

So for example

Code: Select all

screen secret_screen() :
    modal False
    
    imagebutton:
        idle "path to image" 
        hover "path to image" 
        focus_mask True
        xpos 100
        ypos 100
        action Call("secret_scene") 
        
 
label start:
    show screen secret_screen
    "dialogue goes here." 
    hide secret_screen
label more_dialogue:
    "the secret button is gone now. You missed your chance!" 
    return
     
label secret_scene:
    "sacré bleu, but Monsieur, this is a secret. How did you find it!?" 
    return
 
Depending on how you want the game to be structured, you might use Jump, instead of Call.
Last edited by Imperf3kt on Tue Jan 22, 2019 3:00 pm, edited 2 times in total.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: create a secret scene

#3 Post by rayminator »

Or you can do it this way also

make menu first like this and put it at the beginning of the game

Code: Select all

if not (persistent.route1_seen and persistent.route2_seen):
        jump beginning
    menu path_choices:
        nav "selection"
        "Start from beginning":
            jump beginning
        "Start from after OP":
            jump op
        "Risa extra scenario":
            $ route_1 = True
            jump extra1
        "Kana & Kuu extra scenario":
            $ route_2 = True
            jump extra2
        "Seika & Kaie extra scenario":
            $ route_2 = True
            jump extra3

    return
then make a label

Code: Select all

label extra2 or label extra3
and put it at the end of the game

viper
Newbie
Posts: 11
Joined: Mon Jan 21, 2019 4:47 pm
Projects: galaxy
Contact:

Re: create a secret scene

#4 Post by viper »

i think the best for me is the Imperf3kt solution but when i click it continue the story and show the secret scene after

Code: Select all

screen secret() :
    modal False

    imagebutton:
        idle "secret.png"
        hover "secret.png"
        focus_mask True
        xpos 100
        ypos 100
        action Jump("cache")
        
        label start:
        
     show secret
     "bla bla"
     "bla bla"
     "bla bla"
    hide secret

    scene ver6
    "story continue"

    label cache:
        scene ven2
        "secret here" 

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: create a secret scene

#5 Post by Imperf3kt »

You need a return before the secret label, otherwise renpy treats it as part of the previous label (labels are mostly just jump points and renoy ignores them in dialogue flow unless told to go there)

Like this. (there are some indentation issues here that I don't have time to fix.),

Code: Select all

screen secret() :
    modal False

    imagebutton:
        idle "secret.png"
        hover "secret.png"
        focus_mask True
        xpos 100
        ypos 100
        action Jump("cache")
        
label start:
    show secret
        "bla bla"
        "bla bla"
        "bla bla"
    hide secret

    scene ver6
    "story continue"
    
    "story end" 
    return

    label cache:
        scene ven2
        "secret here" 
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

viper
Newbie
Posts: 11
Joined: Mon Jan 21, 2019 4:47 pm
Projects: galaxy
Contact:

Re: create a secret scene

#6 Post by viper »

ok sorry for the "return" now it's good the story continue but when i click on the background i dont jump to the secret scene

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: create a secret scene

#7 Post by Imperf3kt »

Are you clicking on the right spot?
The xpos and ypos in the imagebutton determine the coordinates, which are currently 100 pixels in from both the left and top sides of the screen
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

viper
Newbie
Posts: 11
Joined: Mon Jan 21, 2019 4:47 pm
Projects: galaxy
Contact:

Re: create a secret scene

#8 Post by viper »

sorry i can't answer before, i was click on the spot but nothing.
is it possible to click anyway on the half side of the background for example?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: create a secret scene

#9 Post by Imperf3kt »

Oh I see what's going on, this was my mistake.
I forgot that screens are shown with "show screen", not just "show"

Code: Select all

 
screen secret() :
    modal False

    imagebutton:
        idle "secret.png"
        hover "secret.png"
        focus_mask True
        xpos 100
        ypos 100
        action Jump("cache")
        
label start:
    show screen secret
        "bla bla"
        "bla bla"
        "bla bla"
    hide secret

    scene ver6
    "story continue"
    
    "story end" 
    return

    label cache:
        hide secret
        scene ven2
        "secret here" 
I also forgot to get rid of the button when you access the scene.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

viper
Newbie
Posts: 11
Joined: Mon Jan 21, 2019 4:47 pm
Projects: galaxy
Contact:

Re: create a secret scene

#10 Post by viper »

maybe it's to complicated for me...
now the secret scene dont show

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: create a secret scene

#11 Post by Imperf3kt »

I'm confused. How I previously wrote it was incorrect, it shouldn't have worked at all.

You say it did?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

viper
Newbie
Posts: 11
Joined: Mon Jan 21, 2019 4:47 pm
Projects: galaxy
Contact:

Re: create a secret scene

#12 Post by viper »

with your code the story continue with conversation but on scene ver6 without showing the background of secret.
very sorry for my english.

viper
Newbie
Posts: 11
Joined: Mon Jan 21, 2019 4:47 pm
Projects: galaxy
Contact:

Re: create a secret scene

#13 Post by viper »

sorry my fault! i write xpos 10000 and xpos 10000!
it work but the bg is not full screen
sorry again!!

and the secret dont hide

viper
Newbie
Posts: 11
Joined: Mon Jan 21, 2019 4:47 pm
Projects: galaxy
Contact:

Re: create a secret scene

#14 Post by viper »

ok i found the problem "hide screen secret"
so now i dont have secret bg on full screen and when i click to continue story i automaticly go on secret scene.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: create a secret scene

#15 Post by Imperf3kt »

Is everything working correctly now?
I apologise about not being able to reply in a timely manner.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: Google [Bot]