Fix stickmen photons and neutrons

This commit is contained in:
jacksonmj 2011-03-19 12:00:53 +00:00
parent f316b1fdb9
commit 993fb876c9
2 changed files with 28 additions and 22 deletions

View File

@ -184,9 +184,11 @@ int update_STKM(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
r = photons[y+ry][x+rx];
if (!r || (r>>8)>=NPART) if (!r || (r>>8)>=NPART)
continue; 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 player[2] = r&0xFF; //Current element
} }
@ -225,26 +227,27 @@ int update_STKM(UPDATE_FUNC_ARGS) {
} }
else else
{ {
int np = -1;
if (player[2] == SPC_AIR) 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); create_parts(rx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR);
else else
create_part(-1, rx, ry, player[2]); np = create_part(-1, rx, ry, player[2]);
if ( (np < NPART) && np>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR)
r = pmap[ry][rx]; parts[np].vx = parts[np].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01);
if ( ((r>>8) < NPART) && (r>>8)>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR) if ((np < NPART) && np>=0 && player[2] == PT_PHOT)
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)
{ {
int random = abs(rand()%3-1)*3; int random = abs(rand()%3-1)*3;
if (random==0) if (random==0)
{ {
parts[r>>8].life = 0; kill_part(np);
parts[r>>8].type = PT_NONE;
} }
else else
{ {
parts[r>>8].vy = 0; parts[np].vy = 0;
parts[r>>8].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random; 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;
} }
} }

View File

@ -184,9 +184,11 @@ int update_STKM2(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
r = photons[y+ry][x+rx];
if (!r || (r>>8)>=NPART) if (!r || (r>>8)>=NPART)
continue; 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 player2[2] = r&0xFF; //Current element
} }
@ -225,26 +227,27 @@ int update_STKM2(UPDATE_FUNC_ARGS) {
} }
else else
{ {
int np = -1;
if (player2[2] == SPC_AIR) 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); create_parts(rx + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01), ry, 4, 4, SPC_AIR);
else else
create_part(-1, rx, ry, player2[2]); np = create_part(-1, rx, ry, player2[2]);
if ((np < NPART) && np>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR)
r = pmap[ry][rx]; parts[np].vx = parts[np].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01);
if ( ((r>>8) < NPART) && (r>>8)>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR) if ((np < NPART) && np>=0 && player2[2] == PT_PHOT)
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)
{ {
int random = abs(rand()%3-1)*3; int random = abs(rand()%3-1)*3;
if (random==0) if (random==0)
{ {
parts[r>>8].life = 0; kill_part(np);
parts[r>>8].type = PT_NONE;
} }
else else
{ {
parts[r>>8].vy = 0; parts[np].vy = 0;
parts[r>>8].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random; 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;
} }
} }