Hi,
I am working on a game for my daughter. It is quite simple: I create random additions and let her give the answer. If the answer is Right, she gets a point, if not then not. All this is easy and good and well. Now, I want to show different pictures - like a slide show depending on her answer. So, if she answers wrong, there is a pictire for "wrong" and if she answers right, I want to select a picture randomly to show for "success". This should keep her interest in getting the answers right.
Here is my question:
Can I dynamically change the content of a given image? I know how to define a given image and how to show it on screen. But I am struggling trying to change the content (that is the jpg-file) of the image during the game. I can do the following:
image pic_good_0 = im.Scale("Gut_01.jpg", 1920, 1080)
image pic_good_1 = im.Scale("Gut_02.jpg", 1920, 1080)
image pic_good_2 = im.Scale("Gut_03.jpg", 1920, 1080)
image pic_good_3 = im.Scale("Gut_04.jpg", 1920, 1080)
image pic_good_4 = im.Scale("Gut_05.jpg", 1920, 1080)
image pic_good_5 = im.Scale("Gut_06.jpg", 1920, 1080)
image pic_good_6 = im.Scale("Gut_07.jpg", 1920, 1080)
image pic_good_7 = im.Scale("Gut_08.jpg", 1920, 1080)
image pic_good_8 = im.Scale("Gut_09.jpg", 1920, 1080)
and so on. I can then do a random integer to go into a series of if and elif statements to select, which image to show. But, that seems a bit heavy handed. Can I somehow dynamically create images that point to different jpg-files and change that jpg-file of a given image that I want to show. I couldn't find a way. Is there a way?
Thank you for your help!
[SOLVED] Slide Show with different jpg-files
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.
[SOLVED] Slide Show with different jpg-files
Last edited by Wink3319 on Sat Feb 17, 2024 3:44 am, edited 1 time in total.
- m_from_space
- Miko-Class Veteran
- Posts: 975
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: Slide Show with different jpg-files
That's such a nice little idea, doing something unique for your kid I mean.Wink3319 wrote: ↑Thu Feb 15, 2024 4:00 pm Hi,
I am working on a game for my daughter. It is quite simple: I create random additions and let her give the answer. If the answer is Right, she gets a point, if not then not. All this is easy and good and well. Now, I want to show different pictures - like a slide show depending on her answer. So, if she answers wrong, there is a pictire for "wrong" and if she answers right, I want to select a picture randomly to show for "success". This should keep her interest in getting the answers right.
Here is my question:
Can I dynamically change the content of a given image?
There are multiple ways to do what you want, the easiest way would be to use Renpy's internal ATL system. Make sure to hide the screen after showing it. Only re-showing it will re-select a new picture.
Code: Select all
image random_pic_good:
choice:
"pic_good_0"
choice:
"pic_good_1"
choice:
"pic_good_2"
screen result():
if answer_is_correct:
add "random_pic_good"
else:
add "pic_wrong"
Re: Slide Show with different jpg-files
Hi! Thank you very much for the feedback! I will try this out. Just to make sure: "pic_good_0", "pic_good_1" and so on, would be the file names to fill image random_pic_good, correct? So; i toss random_pic_good on the screen and then it choses between all the files that I put under the choice: property?
Is there a way to combine this with the sizing of the image using im.Scale?
Is there a way to combine this with the sizing of the image using im.Scale?
- m_from_space
- Miko-Class Veteran
- Posts: 975
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: Slide Show with different jpg-files
Exactly.
You don't have to use im.Scale at all to be honest, it's deprecated anyway - I actually cannot even find an entry for it here: https://www.renpy.org/doc/html/im.htmlIs there a way to combine this with the sizing of the image using im.Scale?
Use Frame() instead:The use of image manipulators is historic. A number of image manipulators that had been documented in the past should no longer be used, as they suffer from inherent problems, and in general (except for im.Data()), the Transform() displayable provides similar functionality while fixing the problems.
Code: Select all
image random_pic:
choice:
"Gut_01"
choice:
"Gut_02"
...
screen result():
...
# automatically stretches the picture to the size of the parent (in this case the whole screen)
add Frame("random_pic")
Re: [SOLVED] Slide Show with different jpg-files
Hi, I implemented your recommendation. It works like a charm. Thank you for your support!
Who is online
Users browsing this forum: Majestic-12 [Bot]