[Solved]Different images, same variable?
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.
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.
-
- Regular
- Posts: 39
- Joined: Tue Jul 11, 2017 11:19 pm
- Contact:
[Solved]Different images, same variable?
Hey guys I'm trying to learn how to use Ren'py better and I have an issue that's been on my mind for a while.
Let's say In a game that I'm making I have a character who can wear two outfits. As it is now I have the images coded like so:
image girl dressOne = "dressOne.png"
image girl dressTwo = "dressTwo.png"
whenever I want to display her with her current outfit I use an if statement:
if girlOutfit == 0:
show girl dressOne at right
else:
show girl dressTwo at right
Not only do I dislike this way of coding, but it becomes a big hassle when I add even more outfits to the game.
I tried making a current outfit variable "girl currentOutfit" but assigning that to different image .png file when appropriate does not seem to work.
I know there must be a better way, and I've gone through the tutorial and google several times and I'm not adept enough to figure this out on my own.
Thanks in advance for your help.
Let's say In a game that I'm making I have a character who can wear two outfits. As it is now I have the images coded like so:
image girl dressOne = "dressOne.png"
image girl dressTwo = "dressTwo.png"
whenever I want to display her with her current outfit I use an if statement:
if girlOutfit == 0:
show girl dressOne at right
else:
show girl dressTwo at right
Not only do I dislike this way of coding, but it becomes a big hassle when I add even more outfits to the game.
I tried making a current outfit variable "girl currentOutfit" but assigning that to different image .png file when appropriate does not seem to work.
I know there must be a better way, and I've gone through the tutorial and google several times and I'm not adept enough to figure this out on my own.
Thanks in advance for your help.
Last edited by kylemercury on Fri Dec 21, 2018 6:46 pm, edited 1 time in total.
-
- Regular
- Posts: 39
- Joined: Tue Jul 11, 2017 11:19 pm
- Contact:
Re: Different images, same variable?
I'll check it out, thank you.
Re: Different images, same variable?
You could also look at ConditionalSwitch and DynamicImage
-
- Regular
- Posts: 39
- Joined: Tue Jul 11, 2017 11:19 pm
- Contact:
Re: Different images, same variable?
I might do that, I downloaded the tutorial and it wont launch.
File "game/definitions.rpy", line 9: expected statement.
layeredimage augistina :
There's errors for all the lines that have "layeredimage" like this.
File "game/definitions.rpy", line 9: expected statement.
layeredimage augistina :
There's errors for all the lines that have "layeredimage" like this.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Different images, same variable?
If you aren't doing a layered image (multiple different images layered on top of each other to create one image), then you don't need layered image. ConditionSwitch or DynamicImage will be better for what you want.
DynamicImage is described here:
https://www.renpy.org/doc/html/changelo ... mic-images
https://www.renpy.org/doc/html/displaya ... namicImage
ConditionSwitch is described here:
https://www.renpy.org/doc/html/displaya ... tionSwitch
Also make sure you are updated to the most recent version of RenPy.
DynamicImage is described here:
https://www.renpy.org/doc/html/changelo ... mic-images
https://www.renpy.org/doc/html/displaya ... namicImage
ConditionSwitch is described here:
https://www.renpy.org/doc/html/displaya ... tionSwitch
Also make sure you are updated to the most recent version of RenPy.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
-
- Regular
- Posts: 39
- Joined: Tue Jul 11, 2017 11:19 pm
- Contact:
Re: Different images, same variable?
Appreciated. Thanks for the links.
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Different images, same variable?
Code: Select all
default dress_type = 0
default pose_type = 0
image girl = "images/dress_[dress_type]_pose_[pose_type].png"
label start:
show girl
"..."
$ pose_type = 1 # now shows images/dress_0_pose_1.png
"..."
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Who is online
Users browsing this forum: Google [Bot], Majestic-12 [Bot]