Sprite transformation during dialogue

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
PXL
Newbie
Posts: 21
Joined: Wed Oct 14, 2015 4:48 pm
Contact:

Sprite transformation during dialogue

#1 Post by PXL » Sat Oct 17, 2015 7:57 pm

I have been looking around for a while but have so far been unable to figure out whether this is even possible with the current version of Ren'Py without the use of additional image files.

I am looking for a function that dims the inactive characters (darkens the sprite) currently on the screen (but not talking).

Is this possible? And if so, I would much appreciate an example!

philat
Eileen-Class Veteran
Posts: 1782
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Sprite transformation during dialogue

#2 Post by philat » Sat Oct 17, 2015 8:05 pm

Almost anything is POSSIBLE on Renpy. Doing this efficiently (i.e., by recognizing which character is speaking and dimming all other characters) is a pain in the butt though. Doing it by hand is even more of a pain in the butt. But well, the clues are all available, just a matter of cobbling them together to do what you want.

Darkening images: http://www.renpy.org/doc/html/displayab ... atrixcolor
ConditionSwitch: http://lemmasoft.renai.us/forums/viewto ... 51&t=19063
Character callbacks: http://www.renpy.org/wiki/renpy/doc/coo ... d_Lip_Flap (this is an example of tracking who's speaking -- be warned, it's not easy to understand)

PXL
Newbie
Posts: 21
Joined: Wed Oct 14, 2015 4:48 pm
Contact:

Re: Sprite transformation during dialogue

#3 Post by PXL » Sat Oct 17, 2015 8:32 pm

MatrixColor seems to be what I need, but I am not sure how to call it for individual characters. I honestly don't mind doing it by hand if doing so "only" requires something like:

Code: Select all

show character with MatrixColor

User avatar
Donmai
Eileen-Class Veteran
Posts: 1900
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question
Projects: Slumberland
Location: Brazil
Contact:

Re: Sprite transformation during dialogue

#4 Post by Donmai » Sat Oct 17, 2015 10:28 pm

philat wrote:Almost anything is POSSIBLE on Renpy. Doing this efficiently (i.e., by recognizing which character is speaking and dimming all other characters) is a pain in the butt though.
Maybe this thread could help: http://lemmasoft.renai.us/forums/viewto ... =8&t=34286
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

philat
Eileen-Class Veteran
Posts: 1782
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Sprite transformation during dialogue

#5 Post by philat » Sat Oct 17, 2015 11:04 pm

Donmai wrote:
philat wrote:Almost anything is POSSIBLE on Renpy. Doing this efficiently (i.e., by recognizing which character is speaking and dimming all other characters) is a pain in the butt though.
Maybe this thread could help: http://lemmasoft.renai.us/forums/viewto ... =8&t=34286
...dammit, good catch. I'd been using character callbacks, which are way more of a hassle.

PXL
Newbie
Posts: 21
Joined: Wed Oct 14, 2015 4:48 pm
Contact:

Re: Sprite transformation during dialogue

#6 Post by PXL » Sun Oct 18, 2015 8:02 am

While this sounds great and all, and I really do appreciate the help, I'm not at all familiar with neither Python nor Ren'Py. Would combining MatrixColor, ConditionSwitch, and _last_say_who achieve my goal? That is, to have the sprite of whomever isn't talking darken without the use of new images to do so?

Onishion
Veteran
Posts: 293
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Sprite transformation during dialogue

#7 Post by Onishion » Sun Oct 18, 2015 10:35 pm

I've fiddled with IMMatrixcolor and while it works for a pre-built single image, I had trouble figuring out how to make it work for Composite images.

Anyways, I don't exactly know enough to know exactly how to do this, but wouldn't there be a way to rewrite how the default "say" command works, so that any time you try to just use it normally, it also flags that "character X" is the one speaking, and therefore all "not-character X" would be not speaking?

I've sort of being trying to figure out how to do something similar, to have the game understand that "Bob's" dialog lines are attached to "Bob's" character sprite, and to know where he is on the screen, so that if I place the sprite on the left, the game knows he's on the left, and if I place him on the right, it knows he's on the right, so I can get a word balloon's tail to point in the right direction without having to manually set it each time.

philat
Eileen-Class Veteran
Posts: 1782
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Sprite transformation during dialogue

#8 Post by philat » Mon Oct 19, 2015 12:43 am

PXL wrote:While this sounds great and all, and I really do appreciate the help, I'm not at all familiar with neither Python nor Ren'Py. Would combining MatrixColor, ConditionSwitch, and _last_say_who achieve my goal? That is, to have the sprite of whomever isn't talking darken without the use of new images to do so?
Yes. Define a ConditionSwitch image that uses _last_say_who as a condition to switch between the normal sprite and darkened sprite. (Examples of using im.MatrixColor are in the documentation.) Then show the ConditionSwitch image as you would normally show any other image in your script.

philat
Eileen-Class Veteran
Posts: 1782
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Sprite transformation during dialogue

#9 Post by philat » Mon Oct 19, 2015 2:10 am

Onishion wrote:I've fiddled with IMMatrixcolor and while it works for a pre-built single image, I had trouble figuring out how to make it work for Composite images.

Anyways, I don't exactly know enough to know exactly how to do this, but wouldn't there be a way to rewrite how the default "say" command works, so that any time you try to just use it normally, it also flags that "character X" is the one speaking, and therefore all "not-character X" would be not speaking?

I've sort of being trying to figure out how to do something similar, to have the game understand that "Bob's" dialog lines are attached to "Bob's" character sprite, and to know where he is on the screen, so that if I place the sprite on the left, the game knows he's on the left, and if I place him on the right, it knows he's on the right, so I can get a word balloon's tail to point in the right direction without having to manually set it each time.
Haven't thought about the second part of your question, but I'm bored at work and procastinating today, so gave some thought to the first part. The issue is that image manipulators (all the im. functions like im.Scale, im.Flip, im.Matrixcolor, etc.) only take images, not displayables like LiveComposite. To get around that, I fiddled a bit with AlphaBlend instead.

As a disclaimer, I only tried this with a LiveComposite made up of one image and one ConditionSwitch. As such, I don't know if this is going to be hilariously expensive to run with more complex images, but... so far it works? Not as fancy im.MatrixColor, but it will at least give general tints to images, which is enough to get the job done for this particular use case.

Code: Select all

image livecomp = LiveComposite(define LiveComposite here as normal)

image livecompalpha:
    Flatten("livecomp") # makes a semitransparent version of livecomp to act as the control. Uses Flatten because otherwise, alpha is applied to each layer, making everything weird
    alpha 0.5

image ablivecomp = AlphaBlend("livecompalpha", "livecomp", Solid("#000"), alpha=True) # blends livecomp and the Solid() to darken image

Onishion
Veteran
Posts: 293
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Sprite transformation during dialogue

#10 Post by Onishion » Mon Oct 19, 2015 5:16 am

Interesting. I might try that later and hope by computer doesn't melt when it's applied to by dozens of layers character sprite. ;)

PXL
Newbie
Posts: 21
Joined: Wed Oct 14, 2015 4:48 pm
Contact:

Re: Sprite transformation during dialogue

#11 Post by PXL » Mon Oct 19, 2015 4:07 pm

I feel like my thread may have been hijacked a bit, but I'm glad someone got the answers they needed. I, however, am not using LiveComposite. So if I was to do something like this for several characters, how would the code look and how would I use it?

philat
Eileen-Class Veteran
Posts: 1782
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Sprite transformation during dialogue

#12 Post by philat » Mon Oct 19, 2015 9:27 pm

PXL wrote:I feel like my thread may have been hijacked a bit, but I'm glad someone got the answers they needed. I, however, am not using LiveComposite. So if I was to do something like this for several characters, how would the code look and how would I use it?
philat wrote:Yes. Define a ConditionSwitch image that uses _last_say_who as a condition to switch between the normal sprite and darkened sprite. (Examples of using im.MatrixColor are in the documentation.) Then show the ConditionSwitch image as you would normally show any other image in your script.
Everything you need has been linked to in this thread. At some point, you're going to have to learn to fish. I'm not trying to be antagonistic, I'm trying to calibrate your expectations for this forum.

PXL
Newbie
Posts: 21
Joined: Wed Oct 14, 2015 4:48 pm
Contact:

Re: Sprite transformation during dialogue

#13 Post by PXL » Thu Oct 22, 2015 12:02 pm

philat wrote:Everything you need has been linked to in this thread. At some point, you're going to have to learn to fish. I'm not trying to be antagonistic, I'm trying to calibrate your expectations for this forum.
I'm sorry but I asked for an example exactly because I have no idea of how to put any of this together. :(

philat
Eileen-Class Veteran
Posts: 1782
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Sprite transformation during dialogue

#14 Post by philat » Fri Oct 23, 2015 3:12 am

Why? Again, I'm not trying to be an asshole. I'm asking. What are you having difficulty with (at some level of specificity beyond "everything")? Do you understand what variables are? Do you understand conditions (if A, then B, if not, then C)? Do you understand how ConditionSwitch changes an image based on a variable? Do you understand how im.MatrixColor can be used to darken an image?

Take a stab at putting something together. If it doesn't work, post what you came up with, and we can discuss what went wrong.

User avatar
Donmai
Eileen-Class Veteran
Posts: 1900
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question
Projects: Slumberland
Location: Brazil
Contact:

Re: Sprite transformation during dialogue

#15 Post by Donmai » Fri Oct 23, 2015 8:00 am

Hi, PXL. If you have problems understanding how to use ConditionSwitch, there's a tutorial here: http://lemmasoft.renai.us/forums/viewto ... 51&t=19063
Remember _last_say_who is the variable you want to test.
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

Post Reply

Who is online

Users browsing this forum: godlex, Google [Bot]