allow ACEL and DCEL strength to be modified with ctype

This commit is contained in:
jacob1 2013-02-23 23:42:54 -05:00
parent 20d8eff7f5
commit 6b1e99a731
3 changed files with 28 additions and 4 deletions

View File

@ -3092,6 +3092,12 @@ int Simulation::create_part(int p, int x, int y, int tv)
case PT_TSNS: case PT_TSNS:
parts[i].tmp2 = 2; parts[i].tmp2 = 2;
break; break;
case PT_ACEL:
parts[i].ctype = 10;
break;
case PT_DCEL:
parts[i].ctype = 9;
break;
default: default:
if (t==PT_FIGH) if (t==PT_FIGH)
{ {

View File

@ -61,9 +61,18 @@ int Element_ACEL::update(UPDATE_FUNC_ARGS)
if ((r>>8)>=NPART || !r) if ((r>>8)>=NPART || !r)
continue; continue;
if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))
{
if (parts[i].ctype)
{
int change = parts[i].ctype > 1000 ? 1000 : parts[i].ctype < 0 ? 0 : parts[i].ctype;
parts[r>>8].vx *= 1+change/100.0f;
parts[r>>8].vy *= 1+change/100.0f;
}
else
{ {
parts[r>>8].vx *= 1.1f; parts[r>>8].vx *= 1.1f;
parts[r>>8].vy *= 1.1f; parts[r>>8].vy *= 1.1f;
}
parts[i].tmp = 1; parts[i].tmp = 1;
} }
} }

View File

@ -61,9 +61,18 @@ int Element_DCEL::update(UPDATE_FUNC_ARGS)
if ((r>>8)>=NPART || !r) if ((r>>8)>=NPART || !r)
continue; continue;
if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))
{
if (parts[i].ctype)
{
int change = parts[i].ctype > 100 ? 100 : parts[i].ctype < 0 ? 0 : parts[i].ctype;
parts[r>>8].vx *= 1-change/100.0f;
parts[r>>8].vy *= 1-change/100.0f;
}
else
{ {
parts[r>>8].vx *= 0.9f; parts[r>>8].vx *= 0.9f;
parts[r>>8].vy *= 0.9f; parts[r>>8].vy *= 0.9f;
}
parts[i].tmp = 1; parts[i].tmp = 1;
} }
} }