diff options
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/fwrk.c | 2 | ||||
| -rw-r--r-- | src/elements/prto.c | 8 | ||||
| -rw-r--r-- | src/elements/stkm.c | 25 | ||||
| -rw-r--r-- | src/elements/stkm2.c | 25 |
4 files changed, 33 insertions, 27 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/prto.c b/src/elements/prto.c index 8f743e7..fbbd5a1 100644 --- a/src/elements/prto.c +++ b/src/elements/prto.c @@ -6,8 +6,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) { 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]; @@ -21,8 +21,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]); 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; } } |
