Page 1 of 1
Dynamic Images
Posted: Wed Jan 20, 2010 9:20 pm
by pkt
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.
Re: Dynamic Images
Posted: Thu Jan 21, 2010 12:16 am
by JQuartz
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.
You can use for like so:
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()
Re: Dynamic Images
Posted: Sun Feb 14, 2010 10:15 am
by pkt
Will said images need to be in the init as well?
Re: Dynamic Images
Posted: Sun Feb 14, 2010 11:16 am
by JQuartz
pkt wrote:Will said images need to be in the init as well?
No.
Re: Dynamic Images
Posted: Sun Feb 14, 2010 9:36 pm
by pkt
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.
Re: Dynamic Images
Posted: Thu Feb 18, 2010 10:46 am
by JQuartz
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
I don't really get what exactly you meant but maybe it is something like this:
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
Re: Dynamic Images
Posted: Fri Feb 19, 2010 7:14 pm
by pkt
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.
Re: Dynamic Images
Posted: Sat Feb 20, 2010 5:38 am
by JQuartz
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
Re: Dynamic Images
Posted: Sat Feb 20, 2010 12:58 pm
by pkt
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.
Re: Dynamic Images
Posted: Sun Feb 21, 2010 9:44 am
by JQuartz
pkt wrote:So far none of the Matrix things worked for me with ui image
Try this then:
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
Re: Dynamic Images
Posted: Sat Jun 05, 2010 5:03 pm
by pkt
Thanks, I know it's late and all but this code was a life saver and I finally got it to work.