Changing color of "letterbox" effect mid-game

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
User avatar
carrot_
Newbie
Posts: 22
Joined: Mon Aug 16, 2021 5:19 am
Completed: Easter
Projects: Our Wonderland
itch: carrotpatchgames
Contact:

Changing color of "letterbox" effect mid-game

#1 Post by carrot_ » Mon Aug 16, 2021 5:43 am

Hey, all! First time posting here, but definitely not the first time I've benefited from others' answers here when looking up various issues while working on a game. I come with a potentially odd question that I'm not sure if there's an answer to.

In the game I'm working on, I wanted the "letterbox" effect on the sides when in fullscreen to be white, since the edges of my background images were already white, and this would make it look quite nice on fullscreen no matter the screen size. So I used this code—

Code: Select all

define config.gl_clear_color = "#000"
—listed on the config page to set it to white, and it worked quite nicely.

However, there are a few times throughout the game where I have a completely black screen, and in these cases, the white letterbox ends up looking quite weird and immersion-breaking. I was wondering if there was anyway to update the "config.gl_clear_color" to be black just for these instances. I tried sticking the code in as-is, and it broke the game. This coupled with this description from the config page—"Changing configuration variables outside of init blocks can lead to undefined behavior."—is leading me to believe that it's not possible to update this mid-game, but I wanted to check and see if anyone had any additional insight into this.

Thanks in advance for any help!

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Changing color of "letterbox" effect mid-game

#2 Post by Alex » Mon Aug 16, 2021 12:47 pm

carrot_ wrote:
Mon Aug 16, 2021 5:43 am
... This coupled with this description from the config page—"Changing configuration variables outside of init blocks can lead to undefined behavior."—is leading me to believe that it's not possible to update this mid-game, but I wanted to check and see if anyone had any additional insight into this....
Try to make a variable that can be properly stored and a screen that will change config variable depending of this variable.
Something like

Code: Select all

default bg_color = 'white'

screen my_scr():
    if bg_color == 'white' and config.gl_clear_color != "#fff":
        $ config.gl_clear_color = "#fff"
        
    elif bg_color == 'black' and config.gl_clear_color != "#000":
        $ config.gl_clear_color = "#000"

# The game starts here.
label start:
    show screen my_scr
    "..."
    $ bg_color = 'black'
    "Try to save here..."
    "...and restore game"
    "?!"

User avatar
carrot_
Newbie
Posts: 22
Joined: Mon Aug 16, 2021 5:19 am
Completed: Easter
Projects: Our Wonderland
itch: carrotpatchgames
Contact:

Re: Changing color of "letterbox" effect mid-game

#3 Post by carrot_ » Mon Aug 16, 2021 1:46 pm

Alex wrote:
Mon Aug 16, 2021 12:47 pm

Try to make a variable that can be properly stored and a screen that will change config variable depending of this variable.
Something like

Code: Select all

default bg_color = 'white'

screen my_scr():
    if bg_color == 'white' and config.gl_clear_color != "#fff":
        $ config.gl_clear_color = "#fff"
        
    elif bg_color == 'black' and config.gl_clear_color != "#000":
        $ config.gl_clear_color = "#000"

# The game starts here.
label start:
    show screen my_scr
    "..."
    $ bg_color = 'black'
    "Try to save here..."
    "...and restore game"
    "?!"
Oh gosh, this works perfectly! Thank you so much! :D This will help me rest easier that even those playing without the exact right screen ratio won't have a potentially worse experience.

Post Reply

Who is online

Users browsing this forum: proller