Skip to content

Instantly share code, notes, and snippets.

@zc00gii
Created September 26, 2010 00:17
Show Gist options
  • Select an option

  • Save zc00gii/597443 to your computer and use it in GitHub Desktop.

Select an option

Save zc00gii/597443 to your computer and use it in GitHub Desktop.
else if(t==PT_FUSE)
{
// I do a parts[i].life hack here, the first half bits is for the burn life, the last half bits is for the pressure life
tempu1 = (uint16_t)(((unsigned int)parts[i].life) >> 2);
tempu2 = (uint16_t)(((unsigned int)parts[i].life) & 0x0000FFFF);
if(tempu1<=0) {
t = PT_NONE;
kill_part(i);
r = create_part(-1, x, y, PT_SMKE);
parts[r].temp = 273.15+200.0f;
goto killed;
} else if (tempu1 < 40) {
tempu1--;
r = create_part(-1, (nx=x+rand()%3-1), (ny=y+rand()%3-1), PT_SMKE);
if(0==(rand()%2))
parts[r].temp = 273.15+450.0f;
}
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_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) || (r&0xFF)==PT_SPRK || parts[i].temp>=(273.15+200.0f))
{
if(tempu1>40) {
tempu1 = 39;
}
}
}
parts[i].life = ((uint32_t)tempu1 << 2) & (uint32_t)tempu1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment