summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-03-19 12:00:53 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2011-03-19 12:00:53 (GMT)
commit993fb876c92289a65a24de2264924d074ab3a944 (patch)
treebca2e52a83b09723a4240df8ab164c279bca4a3a /src/elements
parentf316b1fdb927f2ca1c20a5ae58611d6c2cf6d442 (diff)
downloadpowder-993fb876c92289a65a24de2264924d074ab3a944.zip
powder-993fb876c92289a65a24de2264924d074ab3a944.tar.gz
Fix stickmen photons and neutrons
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/stkm.c25
-rw-r--r--src/elements/stkm2.c25
2 files changed, 28 insertions, 22 deletions
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;
}
}