Permalink
Browse files

Now with 100% less =( .

Hot FWRK less laggy.
Define more constant floats.
Pump will now work at x=4,y=4.
Revert a DEUT change
  • Loading branch information...
cracker64 committed Oct 8, 2015
1 parent 3263c94 commit 9a65d60c6ede48c1d4eadeb94133f01031d0ced4
@@ -46,16 +46,17 @@ Element_BCLN::Element_BCLN()
}
#define ADVECTION 0.1f
//#TPT-Directive ElementHeader Element_BCLN static int update(UPDATE_FUNC_ARGS)
int Element_BCLN::update(UPDATE_FUNC_ARGS)
{
if (!parts[i].life && sim->pv[y/CELL][x/CELL]>4.0f)
parts[i].life = rand()%40+80;
if (parts[i].life)
{
float advection = 0.1f;
parts[i].vx += advection*sim->vx[y/CELL][x/CELL];
parts[i].vy += advection*sim->vy[y/CELL][x/CELL];
parts[i].vx += ADVECTION*sim->vx[y/CELL][x/CELL];
parts[i].vy += ADVECTION*sim->vy[y/CELL][x/CELL];
}
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOL)))
{
@@ -58,9 +58,9 @@ int Element_BOYL::update(UPDATE_FUNC_ARGS)
if (sim->pv[y / CELL - 1][x / CELL] < limit)
sim->pv[y / CELL - 1][x / CELL] += 0.001f*(limit - sim->pv[y / CELL - 1][x / CELL]);
sim->pv[y / CELL][x / CELL + 1] += 0.001f*(limit - sim->pv[y / CELL][x / CELL + 1]);
sim->pv[y / CELL][x / CELL + 1] += 0.001f*(limit - sim->pv[y / CELL][x / CELL + 1]);
sim->pv[y / CELL + 1][x / CELL + 1] += 0.001f*(limit - sim->pv[y / CELL + 1][x / CELL + 1]);
sim->pv[y / CELL][x / CELL - 1] += 0.001f*(limit - sim->pv[y / CELL][x / CELL - 1]);
sim->pv[y / CELL][x / CELL - 1] += 0.001f*(limit - sim->pv[y / CELL][x / CELL - 1]);
sim->pv[y / CELL - 1][x / CELL - 1] += 0.001f*(limit - sim->pv[y / CELL - 1][x / CELL - 1]);
for (rx=-1; rx<2; rx++)
@@ -93,7 +93,7 @@ int Element_CLST::update(UPDATE_FUNC_ARGS)
int Element_CLST::graphics(GRAPHICS_FUNC_ARGS)
{
int z =( cpart->tmp - 5) * 16;//speckles!
int z = (cpart->tmp - 5) * 16;//speckles!
*colr += z;
*colg += z;
*colb += z;
@@ -52,7 +52,7 @@ int Element_DEUT::update(UPDATE_FUNC_ARGS)
int r, rx, ry, trade, np;
float gravtot = fabs(sim->gravy[(y/CELL)*(XRES/CELL)+(x/CELL)])+fabs(sim->gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]);
int maxlife = ((10000/(parts[i].temp + 1))-1);
if (!(rand()%((int)parts[i].temp+1)))
if ((10000%((int)parts[i].temp + 1))>rand()%((int)parts[i].temp + 1))
maxlife ++;
// Compress when Newtonian gravity is applied
// multiplier=1 when gravtot=0, multiplier -> 5 as gravtot -> inf
@@ -49,7 +49,7 @@ Element_FWRK::Element_FWRK()
//#TPT-Directive ElementHeader Element_FWRK static int update(UPDATE_FUNC_ARGS)
int Element_FWRK::update(UPDATE_FUNC_ARGS)
{
if (parts[i].life==0 && ((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&surround_space)||parts[i].ctype==PT_DUST))
if (parts[i].life == 0 && ((surround_space && parts[i].temp>400 && (9+parts[i].temp/40)>rand()%100000) || parts[i].ctype == PT_DUST))
{
float gx, gy, multiplier, gmax;
int randTmp;
@@ -51,7 +51,8 @@ int Element_GLAS::update(UPDATE_FUNC_ARGS)
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = sim->pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f)
float diff = parts[i].pavg[1] - parts[i].pavg[0];
if (diff > 0.25f || diff < -0.25f)
{
sim->part_change_type(i,x,y,PT_BGLA);
}
@@ -46,16 +46,17 @@ Element_GOO::Element_GOO()
}
#define ADVECTION 0.1f
//#TPT-Directive ElementHeader Element_GOO static int update(UPDATE_FUNC_ARGS)
int Element_GOO::update(UPDATE_FUNC_ARGS)
{
if (!parts[i].life && sim->pv[y/CELL][x/CELL]>1.0f)
parts[i].life = rand()%80+300;
if (parts[i].life)
{
float advection = 0.1f;
parts[i].vx += advection*sim->vx[y/CELL][x/CELL];
parts[i].vy += advection*sim->vy[y/CELL][x/CELL];
parts[i].vx += ADVECTION*sim->vx[y/CELL][x/CELL];
parts[i].vy += ADVECTION*sim->vy[y/CELL][x/CELL];
}
return 0;
}
@@ -46,6 +46,8 @@ Element_PBCN::Element_PBCN()
Graphics = &Element_PBCN::graphics;
}
#define ADVECTION 0.1f
//#TPT-Directive ElementHeader Element_PBCN static int update(UPDATE_FUNC_ARGS)
int Element_PBCN::update(UPDATE_FUNC_ARGS)
{
@@ -54,9 +56,8 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
parts[i].tmp2 = rand()%40+80;
if (parts[i].tmp2)
{
float advection = 0.1f;
parts[i].vx += advection*sim->vx[y/CELL][x/CELL];
parts[i].vy += advection*sim->vy[y/CELL][x/CELL];
parts[i].vx += ADVECTION*sim->vx[y/CELL][x/CELL];
parts[i].vy += ADVECTION*sim->vy[y/CELL][x/CELL];
parts[i].tmp2--;
if(!parts[i].tmp2){
sim->kill_part(i);
@@ -64,7 +64,7 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS)
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if ((x+rx)-CELL>=0 && (y+ry)-CELL>0 && (x+rx)+CELL<XRES && (y+ry)+CELL<YRES && !(rx && ry))
if (!(rx && ry))
{
sim->pv[(y/CELL)+ry][(x/CELL)+rx] += 0.1f*((parts[i].temp-273.15)-sim->pv[(y/CELL)+ry][(x/CELL)+rx]);
}
@@ -55,22 +55,16 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
if (sim->pv[y/CELL][x/CELL]<singularity)
sim->pv[y/CELL][x/CELL] += 0.1f*(singularity-sim->pv[y/CELL][x/CELL]);
if (y+CELL<YRES && sim->pv[y/CELL+1][x/CELL]<singularity)
if (sim->pv[y/CELL+1][x/CELL]<singularity)
sim->pv[y/CELL+1][x/CELL] += 0.1f*(singularity-sim->pv[y/CELL+1][x/CELL]);
if (x+CELL<XRES)
{
sim->pv[y/CELL][x/CELL+1] += 0.1f*(singularity-sim->pv[y/CELL][x/CELL+1]);
if (y+CELL<YRES)
sim->pv[y/CELL+1][x/CELL+1] += 0.1f*(singularity-sim->pv[y/CELL+1][x/CELL+1]);
}
if (y-CELL>=0 && sim->pv[y/CELL-1][x/CELL]<singularity)
if (sim->pv[y/CELL-1][x/CELL]<singularity)
sim->pv[y/CELL-1][x/CELL] += 0.1f*(singularity-sim->pv[y/CELL-1][x/CELL]);
if (x-CELL>=0)
{
sim->pv[y/CELL][x/CELL-1] += 0.1f*(singularity-sim->pv[y/CELL][x/CELL-1]);
if (y-CELL>=0)
sim->pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-sim->pv[y/CELL-1][x/CELL-1]);
}
sim->pv[y/CELL][x/CELL+1] += 0.1f*(singularity-sim->pv[y/CELL][x/CELL+1]);
sim->pv[y/CELL+1][x/CELL+1] += 0.1f*(singularity-sim->pv[y/CELL+1][x/CELL+1]);
sim->pv[y/CELL][x/CELL-1] += 0.1f*(singularity-sim->pv[y/CELL][x/CELL-1]);
sim->pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-sim->pv[y/CELL-1][x/CELL-1]);
if (parts[i].life<1) {
//Pop!
for (rx=-1; rx<2; rx++) {
@@ -93,10 +93,11 @@ int Element_TUNG::update(UPDATE_FUNC_ARGS)
parts[i].vx += (rand()%100)-50;
parts[i].vy += (rand()%100)-50;
return 1;
}
}
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = sim->pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.50f || parts[i].pavg[1]-parts[i].pavg[0] < -0.50f)
float diff = parts[i].pavg[1] - parts[i].pavg[0];
if (diff > 0.50f || diff < -0.50f)
{
sim->part_change_type(i,x,y,PT_BRMT);
parts[i].ctype = PT_TUNG;
@@ -57,8 +57,7 @@ int Element_URAN::update(UPDATE_FUNC_ARGS)
}
else
{
float atemp = parts[i].temp + (-MIN_TEMP);
parts[i].temp = restrict_flt((atemp*(1+(sim->pv[y/CELL][x/CELL]/2000)))+MIN_TEMP, MIN_TEMP, MAX_TEMP);
parts[i].temp = restrict_flt((parts[i].temp*(1 + (sim->pv[y / CELL][x / CELL] / 2000))) + MIN_TEMP, MIN_TEMP, MAX_TEMP);
}
}
return 0;
@@ -48,7 +48,7 @@ Element_WIFI::Element_WIFI()
//#TPT-Directive ElementHeader Element_WIFI static int update(UPDATE_FUNC_ARGS)
int Element_WIFI::update(UPDATE_FUNC_ARGS)
{
{
int r, rx, ry;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
@@ -83,16 +83,15 @@ int Element_WIFI::update(UPDATE_FUNC_ARGS)
return 0;
}
#define FREQUENCY 0.0628f
//#TPT-Directive ElementHeader Element_WIFI static int graphics(GRAPHICS_FUNC_ARGS)
int Element_WIFI::graphics(GRAPHICS_FUNC_ARGS)
{
float frequency = 0.0628;
int q = (int)((cpart->temp-73.15f)/100+1);
*colr = sin(frequency*q + 0) * 127 + 128;
*colg = sin(frequency*q + 2) * 127 + 128;
*colb = sin(frequency*q + 4) * 127 + 128;
*colr = sin(FREQUENCY*q + 0) * 127 + 128;
*colg = sin(FREQUENCY*q + 2) * 127 + 128;
*colb = sin(FREQUENCY*q + 4) * 127 + 128;
*pixel_mode |= EFFECT_DBGLINES;
return 0;
}

0 comments on commit 9a65d60

Please sign in to comment.