Cracker suggestion, fixed newly generated Quartz to always have color of previous particle it was created from. Makes cool patterns. Also increased speed.

This commit is contained in:
Cate
2011-03-24 14:50:27 -04:00
committed by Simon
parent bb0907bc96
commit 7bfe412e29

View File

@@ -1,14 +1,13 @@
#include <element.h>
int update_QRTZ(UPDATE_FUNC_ARGS) {
int r, tmp, trade, rx, ry;
int r, tmp, trade, rx, ry, np;
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3))
{
part_change_type(i,x,y,PT_PQRT);
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
@@ -16,14 +15,13 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
else if ((r&0xFF)==PT_SLTW && (1>rand()%5000))
else if ((r&0xFF)==PT_SLTW && (1>rand()%2500))
{
kill_part(r>>8);
parts[i].life = 1;
}
}
if (parts[i].life==1)
{
for (rx=-1; rx<2; rx++)
@@ -33,14 +31,12 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || r)
continue;
create_part(-1,x+rx,y+ry,PT_QRTZ);
np = create_part(-1,x+rx,y+ry,PT_QRTZ);
if (np<0) continue;
parts[np].tmp = parts[i].tmp;
parts[i].life = 0;
}
}
for ( trade = 0; trade<9; trade ++)
{
rx = rand()%5-2;
@@ -68,7 +64,5 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
}
}
}
return 0;
}