Displaying day/night sprite with variable

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
SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Displaying day/night sprite with variable

#1 Post by SundownKid » Wed Oct 03, 2012 3:58 pm

I am looking for a way to switch between the day or night versions of a sprite without having to type in "show dude normal night at center". Basically, I am looking to change a variable such as "daytime = True" and have the character sprite automatically switch to the daytime image. Is there any way to do that when you define the image?

User avatar
Stainless_Steel
Regular
Posts: 56
Joined: Mon Jun 25, 2012 11:03 pm
Location: TX, USA
Contact:

Re: Displaying day/night sprite with variable

#2 Post by Stainless_Steel » Wed Oct 03, 2012 6:23 pm

You could try a condition switch:

Code: Select all

image character = ConditionSwitch(
        "time_of_day == 'day'", "character_day.jpg",
        "time_of_day == 'night'", "character_night.jpg",
        )
then you just switch using the variables

Code: Select all

$ time_of_day= day 
$ time_of_day = night
Though it'd get more complicated if your making the day and night versions by tinting the image in renpy, not sure how you'd do it then.

User avatar
junna
Veteran
Posts: 347
Joined: Sat Sep 08, 2012 4:16 am
Projects: DreamWalker; History; Adversity Competition
Contact:

Re: Displaying day/night sprite with variable

#3 Post by junna » Wed Oct 03, 2012 6:37 pm

Stainless_Steel wrote:You could try a condition switch:

Code: Select all

image character = ConditionSwitch(
        "time_of_day == 'day'", "character_day.jpg",
        "time_of_day == 'night'", "character_night.jpg",
        )
then you just switch using the variables

Code: Select all

$ time_of_day= day 
$ time_of_day = night
Though it'd get more complicated if your making the day and night versions by tinting the image in renpy, not sure how you'd do it then.
doing it with image tints could mean that you have to tint the characters first

Code: Select all

image characternight = im.MatrixColor("characterday.jpg",
                                       im.matrix.saturation(0.5)*im.matrix.tint(.44,.44,.93)*im.matrix.brightness(-0.05))
(the tint I used is a purplish-blue colour) then using it as...

Code: Select all

image character = ConditionSwitch(
        "time_of_day == 'day'", "character_day.jpg",
        "time_of_day == 'night'", ImageReference ("characternight"),
        )
lol. that was guesswork. but I hope it worked.
chibi avvie by Meg (buprettyinpink).
WIP=>Image
Image<=helping out

User avatar
SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: Displaying day/night sprite with variable

#4 Post by SundownKid » Thu Oct 04, 2012 6:08 am

Thanks! This works perfectly - now my characters can have night versions.

Post Reply

Who is online

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