diff options
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/fwrk.c | 2 | ||||
| -rw-r--r-- | src/elements/prti.c | 32 | ||||
| -rw-r--r-- | src/elements/prto.c | 37 | ||||
| -rw-r--r-- | src/elements/qrtz.c | 55 | ||||
| -rw-r--r-- | src/elements/sing.c | 38 | ||||
| -rw-r--r-- | src/elements/stkm.c | 25 | ||||
| -rw-r--r-- | src/elements/stkm2.c | 25 |
7 files changed, 184 insertions, 30 deletions
diff --git a/src/elements/fwrk.c b/src/elements/fwrk.c index 06390c5..5095cde 100644 --- a/src/elements/fwrk.c +++ b/src/elements/fwrk.c @@ -16,7 +16,7 @@ int update_FWRK(UPDATE_FUNC_ARGS) { } if (parts[i].life>=45) parts[i].life=0; - if ((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0) + if ((parts[i].life<3&&parts[i].life>0)||(parts[i].vy>6&&parts[i].life>0)) { int q = (rand()%255+1); int w = (rand()%255+1); diff --git a/src/elements/prti.c b/src/elements/prti.c index 560ba8c..fa87562 100644 --- a/src/elements/prti.c +++ b/src/elements/prti.c @@ -1,7 +1,7 @@ #include <element.h> int update_PRTI(UPDATE_FUNC_ARGS) { - int r, nnx, rx, ry; + int r, nnx, rx, ry, fe = 0; int count =0; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; @@ -12,6 +12,8 @@ int update_PRTI(UPDATE_FUNC_ARGS) { { r = pmap[y+ry][x+rx]; count ++; + if (!r) + fe = 1; if ((r>>8)>=NPART || !r) continue; if ((r&0xFF)==PT_SPRK || ((r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO && (ptypes[r&0xFF].falldown!= 0 || ptypes[r&0xFF].state == ST_GAS))) @@ -28,5 +30,33 @@ int update_PRTI(UPDATE_FUNC_ARGS) { break; } } + + + if(fe){ + if(!parts[i].life) parts[i].life = rand(); + if(!parts[i].ctype) parts[i].life = rand(); + int orbd[4] = {0, 0, 0, 0}; //Orbital distances + int orbl[4] = {0, 0, 0, 0}; //Orbital locations + orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); + for(r = 0; r < 4; r++){ + if(orbd[r]>1){ + orbd[r] -= 12; + if(orbd[r]<1){ + orbd[r] = (rand()%128)+128; + orbl[r] = rand()%255; + } else { + orbl[r] += 2; + orbl[r] = orbl[r]%255; + } + } else { + orbd[r] = (rand()%128)+128; + orbl[r] = rand()%255; + } + } + orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); + } else { + parts[i].life = 0; + parts[i].ctype = 0; + } return 0; } diff --git a/src/elements/prto.c b/src/elements/prto.c index 8f743e7..9bec996 100644 --- a/src/elements/prto.c +++ b/src/elements/prto.c @@ -1,17 +1,19 @@ #include <element.h> int update_PRTO(UPDATE_FUNC_ARGS) { - int r, nnx, rx, ry, np; + int r, nnx, rx, ry, np, fe = 0; int count = 0; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; else if (parts[i].tmp<0) parts[i].tmp = 0; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) + for (rx=1; rx>-2; rx--) + for (ry=1; ry>-2; ry--) if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) { r = pmap[y+ry][x+rx]; count ++; + if (!r) + fe = 1; if ((r>>8)>=NPART || r) continue; if (!r) @@ -21,8 +23,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) { int randomness = count + rand()%3-1; if (randomness<1) randomness=1; - if (randomness>8) - randomness=8; + if (randomness>9) + randomness=9; if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)// TODO: make it look better { create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]); @@ -51,5 +53,30 @@ int update_PRTO(UPDATE_FUNC_ARGS) { } } } + if(fe){ + if(!parts[i].life) parts[i].life = rand(); + if(!parts[i].ctype) parts[i].life = rand(); + int orbd[4] = {0, 0, 0, 0}; //Orbital distances + int orbl[4] = {0, 0, 0, 0}; //Orbital locations + orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); + for(r = 0; r < 4; r++){ + if(orbd[r]<254){ + orbd[r] += 16; + if(orbd[r]>254){ + orbd[r] = 0; + orbl[r] = rand()%255; + } + //orbl[r] += 1; + //orbl[r] = orbl[r]%255; + } else { + orbd[r] = 0; + orbl[r] = rand()%255; + } + } + orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); + } else { + parts[i].life = 0; + parts[i].ctype = 0; + } return 0; } diff --git a/src/elements/qrtz.c b/src/elements/qrtz.c index 74d8c99..e585361 100644 --- a/src/elements/qrtz.c +++ b/src/elements/qrtz.c @@ -1,11 +1,66 @@ #include <element.h> int update_QRTZ(UPDATE_FUNC_ARGS) { + 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)) + { + r = pmap[y+ry][x+rx]; + if ((r>>8)>=NPART || !r) + continue; + else if ((r&0xFF)==PT_SLTW && (1>rand()%2500)) + { + kill_part(r>>8); + parts[i].life ++; + } + } + if (parts[i].life>0) + { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) + { + r = pmap[y+ry][x+rx]; + if ((r>>8)>=NPART || r || parts[i].life==0) continue; + 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; + ry = rand()%5-2; + if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) + { + r = pmap[y+ry][x+rx]; + if ((r>>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_QRTZ&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion + { + tmp = parts[i].life - parts[r>>8].life; + if (tmp ==1) + { + parts[r>>8].life ++; + parts[i].life --; + trade = 9; + } + if (tmp>0) + { + parts[r>>8].life += tmp/2; + parts[i].life -= tmp/2; + trade = 9; + } + } + } + } return 0; } diff --git a/src/elements/sing.c b/src/elements/sing.c index 02f5eaf..4514726 100644 --- a/src/elements/sing.c +++ b/src/elements/sing.c @@ -1,7 +1,7 @@ #include <element.h> int update_SING(UPDATE_FUNC_ARGS) { - int r, rx, ry; + int r, rx, ry, cry, crx, rad, nxi, nxj, nb; int singularity = -parts[i].life; if (pv[y/CELL][x/CELL]<singularity) @@ -22,6 +22,41 @@ int update_SING(UPDATE_FUNC_ARGS) { if (y+CELL>0) pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]); } + if(parts[i].life<1){ + //Pop! + for(rx=-2; rx<3; rx++){ + crx = (x/CELL)+rx; + for(ry=-2; ry<3; ry++){ + cry = (y/CELL)+ry; + if(cry > 0 && crx > 0 && crx < (XRES/CELL) && cry < (YRES/CELL)){ + pv[cry][crx] += (float)parts[i].tmp; + } + } + } + rad = (parts[i].tmp>255)?255:parts[i].tmp; + if(rad>=1){ + rad = (int)(((float)rad)/8.0f); + } + if(rad>=1){ + for (nxj=-(rad+1); nxj<=(rad+1); nxj++) + for (nxi=-(rad+1); nxi<=(rad+1); nxi++) + if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1) { + if(rand()%2){ + nb = create_part(-1, x+nxi, y+nxj, PT_PHOT); + } else { + nb = create_part(-1, x+nxi, y+nxj, PT_NEUT); + } + if (nb!=-1) { + parts[nb].life = rand()%300; + parts[nb].temp = MAX_TEMP/2; + parts[nb].vx = rand()%10-5; + parts[nb].vy = rand()%10-5; + } + } + } + kill_part(i); + return 1; + } for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) @@ -50,6 +85,7 @@ int update_SING(UPDATE_FUNC_ARGS) { continue; } parts[i].life += 3; + parts[i].tmp++; } parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP); kill_part(r>>8); diff --git a/src/elements/stkm.c b/src/elements/stkm.c index 6d6b4ab..fc6dc55 100644 --- a/src/elements/stkm.c +++ b/src/elements/stkm.c @@ -185,8 +185,10 @@ int update_STKM(UPDATE_FUNC_ARGS) { { r = pmap[y+ry][x+rx]; if (!r || (r>>8)>=NPART) + r = photons[y+ry][x+rx]; + if (!r || (r>>8)>=NPART) continue; - if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) // TODO: photons are not in the pmap. This line may not work as intended. + if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) { player[2] = r&0xFF; //Current element } @@ -225,26 +227,27 @@ int update_STKM(UPDATE_FUNC_ARGS) { } else { + int np = -1; if (player[2] == SPC_AIR) create_parts(rx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR); else - create_part(-1, rx, ry, player[2]); - - r = pmap[ry][rx]; - if ( ((r>>8) < NPART) && (r>>8)>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR) - parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01); - if (((r>>8) < NPART) && (r>>8)>=0 && player[2] == PT_PHOT) + np = create_part(-1, rx, ry, player[2]); + if ( (np < NPART) && np>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR) + parts[np].vx = parts[np].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01); + if ((np < NPART) && np>=0 && player[2] == PT_PHOT) { int random = abs(rand()%3-1)*3; if (random==0) { - parts[r>>8].life = 0; - parts[r>>8].type = PT_NONE; + kill_part(np); } else { - parts[r>>8].vy = 0; - parts[r>>8].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random; + parts[np].vy = 0; + if (((int)player[1])&(0x01|0x02)) + parts[np].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random; + else + parts[np].vx = random; } } diff --git a/src/elements/stkm2.c b/src/elements/stkm2.c index 319e388..79dbbdf 100644 --- a/src/elements/stkm2.c +++ b/src/elements/stkm2.c @@ -185,8 +185,10 @@ int update_STKM2(UPDATE_FUNC_ARGS) { { r = pmap[y+ry][x+rx]; if (!r || (r>>8)>=NPART) + r = photons[y+ry][x+rx]; + if (!r || (r>>8)>=NPART) continue; - if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) // TODO: photons are not in the pmap. This line may not work as intended. + if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) { player2[2] = r&0xFF; //Current element } @@ -225,26 +227,27 @@ int update_STKM2(UPDATE_FUNC_ARGS) { } else { + int np = -1; if (player2[2] == SPC_AIR) create_parts(rx + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR); else - create_part(-1, rx, ry, player2[2]); - - r = pmap[ry][rx]; - if ( ((r>>8) < NPART) && (r>>8)>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR) - parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01); - if (((r>>8) < NPART) && (r>>8)>=0 && player2[2] == PT_PHOT) + np = create_part(-1, rx, ry, player2[2]); + if ((np < NPART) && np>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR) + parts[np].vx = parts[np].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01); + if ((np < NPART) && np>=0 && player2[2] == PT_PHOT) { int random = abs(rand()%3-1)*3; if (random==0) { - parts[r>>8].life = 0; - parts[r>>8].type = PT_NONE; + kill_part(np); } else { - parts[r>>8].vy = 0; - parts[r>>8].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random; + parts[np].vy = 0; + if (((int)player2[1])&(0x01|0x02)) + parts[np].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random; + else + parts[np].vx = random; } } |
