The Powder Toy
Download
Forum
Browse
Wiki
FAQ
Play online
Register
Login
Discussions
/
Development Assistance
/
One direction growth
«
1
»
One direction growth
PizzaPlatypus
22nd Dec 2010
Member
0
Permalink
I've made an element that I want to make grow but only in one direction:
Upwards. How can I do this?
tian110796
22nd Dec 2010
Member
0
Permalink
Does it grow slowly or not?
if not:
delete_part(x, y-1);
create_part(-1, x, y-1, PT_GROW);
if yes:
if(rand()%slow < 1){
delete_part(x, y-1);
create_part(-1, x, y-1, PT_GROW);
}
where PT_GROW is the element that grows and slow is an integer in the rate it is growing (the higher, the slower).
MiXih
22nd Dec 2010
Member
0
Permalink
if(t==ELEMENTTHATYOUWANTTOGROWUPWARDS)
{
create_part(-1,parts[i].x,parts[i].y-1,ELEMENTTHATYOUWANTTOGROWUPWARDS);
}
if you want to use
tian110796
s method, change "x, y-1," to "parts[i].x,parts[i].y-1,"
tian110796
22nd Dec 2010
Member
0
Permalink
wikku9:
change "x, y-1," to "parts[i].x,parts[i].y-1,"
No need. x and y are already set to parts[i].x and parts[i].y before anything have reacted.
yew101
22nd Dec 2010
Member
0
Permalink
ok here would be the code for plant to only grow directly up (powder.c line.2178) i have edited the pat in bold to make do so:
else if(t==PT_PLNT)
{
for(nx=-2; nx<3; nx++)
for(ny=-2; ny<3; ny++)
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES && (nx || ny))
{
r = pmap[y+ny][x+nx];
if((r>>8)>=NPART || !r)
continue;
if((r&0xFF)==PT_WATR && 1>(rand()%250))
{
delete_part(x, y-1);
create_part(-1, x, y-1, PT_PLNT);
}
else if((r&0xFF)==PT_LAVA && 1>(rand()%250))
{
parts[i].life = 4;
t = parts[i].type = PT_FIRE;
}
PizzaPlatypus
22nd Dec 2010
Member
0
Permalink
Thanks guys I'll try.
PizzaPlatypus
22nd Dec 2010
Member
0
Permalink
Sometimes it jumps instead of running smoothly.
pilojo
22nd Dec 2010
Member
0
Permalink
PizzaPlatypus
Well, what are you doing? Just randomly grows upwards? or something like plant.. where something has to touch it.
Finalflash50
22nd Dec 2010
Banned
0
Permalink
This post is hidden because the user is banned
PizzaPlatypus
22nd Dec 2010
Member
0
Permalink
Wait, it works
«
1
»