Dynamic Images
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.
-
- Veteran
- Posts: 322
- Joined: Tue Jul 28, 2009 10:09 pm
- Completed: I dunno
- Projects: Something special
- Contact:
Dynamic Images
I'm working on a character maker program based on renpy. I need code to dynamically load images of a certain prefix and put them in a list so they can be addressed by number. Like head01.png-head32.png can be loaded at once. Head pic 32 called as $ head = 32 or something simple like that.
No Active Public Renpy Projects...
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Dynamic Images
You can use for like so:pkt wrote:I need code to dynamically load images of a certain prefix and put them in a list so they can be addressed by number. Like head01.png-head32.png can be loaded at once.
Code: Select all
label start:
python:
ui.vbox()
for num in range(1, 33):
if num>9:
ui.image("head"+str(num)+".png")
elif num<=9:
ui.image("head0"+str(num)+".png")
ui.close()
renpy.pause()
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
-
- Veteran
- Posts: 322
- Joined: Tue Jul 28, 2009 10:09 pm
- Completed: I dunno
- Projects: Something special
- Contact:
Re: Dynamic Images
Will said images need to be in the init as well?
No Active Public Renpy Projects...
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Dynamic Images
No.pkt wrote:Will said images need to be in the init as well?
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
-
- Veteran
- Posts: 322
- Joined: Tue Jul 28, 2009 10:09 pm
- Completed: I dunno
- Projects: Something special
- Contact:
Re: Dynamic Images
It was somewhat going to use layers of different image sets like one for eyes another for hair and clothes and rotate a value based on button presses. There was going to be a color thing too. I'm a little used to C++ so it might look a little like this in that. I'm really rusty though.
Here's proto code
hair[hair_number,hair_color,hair_darkness]
if hair_number>=4
hair_number=0
...
if hair_number == 1
hair_01.png
if hair_number == 2
hair_02.png
but then wrap that in something to call the hair as a variable
then process the color in and value in as well.
Yeah I know it looks horrible but hoping it helps.
Here's proto code
hair[hair_number,hair_color,hair_darkness]
if hair_number>=4
hair_number=0
...
if hair_number == 1
hair_01.png
if hair_number == 2
hair_02.png
but then wrap that in something to call the hair as a variable
then process the color in and value in as well.
Yeah I know it looks horrible but hoping it helps.
No Active Public Renpy Projects...
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Dynamic Images
I don't really get what exactly you meant but maybe it is something like this:pkt wrote:It was somewhat going to use layers of different image sets like one for eyes another for hair and clothes and rotate a value based on button presses
Code: Select all
init:
$ hair_number=1
label select_hair:
python:
if hair_number>=4:
hair_number=0
ui.vbox()
ui.textbutton("Next", ui.jumps("next_hair"))
ui.image("hair_0"+str(hair_number)+".png")
ui.close()
ui.interact()
label next_hair:
$ hair_number+=1
jump select_hair
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
-
- Veteran
- Posts: 322
- Joined: Tue Jul 28, 2009 10:09 pm
- Completed: I dunno
- Projects: Something special
- Contact:
Re: Dynamic Images
This code was needed to get my recode of the character maker working. So far everything but changing colors works now. That's the last frontier.
No Active Public Renpy Projects...
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Dynamic Images
You can try using im.MatrixColor to change the color like so:
Code: Select all
init:
$ hair_number=1
$ valueb=0
label select_hair:
python:
if hair_number>=4:
hair_number=0
ui.vbox()
ui.textbutton("Add valueb", ui.jumps("add_valueb"))
ui.textbutton("Reduce valueb", ui.jumps("reduce_valueb"))
ui.textbutton("Next", ui.jumps("next_hair"))
ui.image(im.MatrixColor("s_image"+str(hair_number)+".png",
[ -1, valueb, 0, 0, 1,
0, -1, 0, 0, 1,
0, 0, -1, 0, 1,
0, 0, 0, 1, 0, ])) #set the other value in the matrix as variable
ui.close()
ui.interact()
label next_hair:
$ hair_number+=1
jump select_hair
label add_valueb:
$ valueb+=1
jump select_hair
label reduce_valueb:
$ valueb-=1
jump select_hair
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
-
- Veteran
- Posts: 322
- Joined: Tue Jul 28, 2009 10:09 pm
- Completed: I dunno
- Projects: Something special
- Contact:
Re: Dynamic Images
Here's the script.rpy. So far none of the Matrix things worked for me with ui image. It's for a character maker thing.
- Attachments
-
- script.rpy
- (3.72 KiB) Downloaded 38 times
No Active Public Renpy Projects...
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Dynamic Images
Try this then:pkt wrote:So far none of the Matrix things worked for me with ui image
Code: Select all
init:
$ hair_number=1
$ valueb=0
label start:
pass
label select_hair:
python:
if hair_number>=4:
hair_number=0
ui.vbox()
ui.textbutton("Add valueb", ui.jumps("add_valueb"))
ui.textbutton("Reduce valueb", ui.jumps("reduce_valueb"))
ui.textbutton("Next", ui.jumps("next_hair"))
ui.image(im.MatrixColor("hair_0"+str(hair_number)+".png", im.matrix.hue(valueb)))
ui.close()
ui.interact()
label next_hair:
$ hair_number+=1
jump select_hair
label add_valueb:
$ valueb+=10
jump select_hair
label reduce_valueb:
$ valueb-=10
jump select_hair
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
-
- Veteran
- Posts: 322
- Joined: Tue Jul 28, 2009 10:09 pm
- Completed: I dunno
- Projects: Something special
- Contact:
Re: Dynamic Images
Thanks, I know it's late and all but this code was a life saver and I finally got it to work.
No Active Public Renpy Projects...
Who is online
Users browsing this forum: Google [Bot]