diff options
| author | jacob1 <jfu614@gmail.com> | 2013-05-30 00:36:34 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-05-30 00:36:34 (GMT) |
| commit | d6d20defdebf72c2b27244a6d4bc8a757a669a59 (patch) | |
| tree | a3802256a9377cf5b048a01a91a31a470be3c7c3 /src/simulation/Simulation.cpp | |
| parent | cbc80de6522b5562f9490b0cdb620371f25be2f9 (diff) | |
| parent | 41e369e68eac7b05f8cda312f9668942dc688aa7 (diff) | |
| download | powder-d6d20defdebf72c2b27244a6d4bc8a757a669a59.zip powder-d6d20defdebf72c2b27244a6d4bc8a757a669a59.tar.gz | |
Merge branch 'master' of git@github.com:FacialTurd/The-Powder-Toy.git
Diffstat (limited to 'src/simulation/Simulation.cpp')
| -rw-r--r-- | src/simulation/Simulation.cpp | 132 |
1 files changed, 60 insertions, 72 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 4c1a543..77cb586 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2915,6 +2915,7 @@ int Simulation::create_part(int p, int x, int y, int tv) } else { + parts[i].type=0; return -1; } create_part(-3,x,y,PT_SPAWN); @@ -2930,6 +2931,7 @@ int Simulation::create_part(int p, int x, int y, int tv) } else { + parts[i].type=0; return -1; } create_part(-3,x,y,PT_SPAWN2); @@ -2943,84 +2945,70 @@ int Simulation::create_part(int p, int x, int y, int tv) case PT_TSNS: parts[i].tmp2 = 2; break; - default: - if (t==PT_FIGH) - { - unsigned char fcount = 0; - while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++; - if (fcount < 100 && fighters[fcount].spwn==0) - { - parts[i].x = (float)x; - parts[i].y = (float)y; - parts[i].type = PT_FIGH; - parts[i].vx = 0; - parts[i].vy = 0; - parts[i].life = 100; - parts[i].ctype = 0; - parts[i].tmp = fcount; - parts[i].temp = elements[t].Temperature; - Element_STKM::STKM_init_legs(this, &fighters[fcount], i); - fighters[fcount].spwn = 1; - fighters[fcount].elem = PT_DUST; - fighters[fcount].rocketBoots = false; - fighcount++; - - return i; - } - return -1; - } - if (t==PT_PHOT) - { - float a = (rand()%8) * 0.78540f; - parts[i].life = 680; - parts[i].ctype = 0x3FFFFFFF; - parts[i].vx = 3.0f*cosf(a); - parts[i].vy = 3.0f*sinf(a); - } - if (t==PT_ELEC) - { - float a = (rand()%360)*3.14159f/180.0f; - parts[i].life = 680; - parts[i].vx = 2.0f*cosf(a); - parts[i].vy = 2.0f*sinf(a); - } - if (t==PT_NEUT) + case PT_FIGH:{ + unsigned char fcount = 0; + while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++; + if (fcount < 100 && fighters[fcount].spwn==0) { - float r = (rand()%128+128)/127.0f; - float a = (rand()%360)*3.14159f/180.0f; - parts[i].life = rand()%480+480; - parts[i].vx = r*cosf(a); - parts[i].vy = r*sinf(a); + parts[i].life = 100; + parts[i].tmp = fcount; + Element_STKM::STKM_init_legs(this, &fighters[fcount], i); + fighters[fcount].spwn = 1; + fighters[fcount].elem = PT_DUST; + fighters[fcount].rocketBoots = false; + fighcount++; + return i; } - if (t==PT_TRON) + parts[i].type=0; + return -1;} + case PT_PHOT:{ + float a = (rand()%8) * 0.78540f; + parts[i].life = 680; + parts[i].ctype = 0x3FFFFFFF; + parts[i].vx = 3.0f*cosf(a); + parts[i].vy = 3.0f*sinf(a); + break;} + case PT_ELEC:{ + float a = (rand()%360)*3.14159f/180.0f; + parts[i].life = 680; + parts[i].vx = 2.0f*cosf(a); + parts[i].vy = 2.0f*sinf(a); + break;} + case PT_NEUT:{ + float r = (rand()%128+128)/127.0f; + float a = (rand()%360)*3.14159f/180.0f; + parts[i].life = rand()%480+480; + parts[i].vx = r*cosf(a); + parts[i].vy = r*sinf(a); + break;} + case PT_TRON:{ + int randhue = rand()%360; + int randomdir = rand()%4; + parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction + parts[i].tmp2 = 4;//tail + parts[i].life = 5; + break;} + case PT_LIGH:{ + float gx, gy, gsize; + if (p!=-2) { - int randhue = rand()%360; - int randomdir = rand()%4; - parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction - parts[i].tmp2 = 4;//tail - parts[i].life = 5; + parts[i].life=30; + parts[i].temp=parts[i].life*150.0f; // temperature of the lighting shows the power of the lighting } - if (t==PT_LIGH) + GetGravityField(x, y, 1.0f, 1.0f, gx, gy); + gsize = gx*gx+gy*gy; + if (gsize<0.0016f) { - float gx, gy, gsize; - if (p!=-2) - { - parts[i].life=30; - parts[i].temp=parts[i].life*150.0f; // temperature of the lighting shows the power of the lighting - } - GetGravityField(x, y, 1.0f, 1.0f, gx, gy); - gsize = gx*gx+gy*gy; - if (gsize<0.0016f) - { - float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi) - gsize = sqrtf(gsize); - // randomness in weak gravity fields (more randomness with weaker fields) - gx += cosf(angle)*(0.04f-gsize); - gy += sinf(angle)*(0.04f-gsize); - } - parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+rand()%40-20+360)%360; - parts[i].tmp2 = 4; + float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi) + gsize = sqrtf(gsize); + // randomness in weak gravity fields (more randomness with weaker fields) + gx += cosf(angle)*(0.04f-gsize); + gy += sinf(angle)*(0.04f-gsize); } + parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+rand()%40-20+360)%360; + parts[i].tmp2 = 4; + break;} + default: break; } //and finally set the pmap/photon maps to the newly created particle |
