Change portal so that randomness never causes a particle to exit the same side it came in
This commit is contained in:
parent
20aba663cd
commit
5f8fba12c8
@ -946,6 +946,8 @@ static wall_type wtypes[] =
|
|||||||
particle portalp[CHANNELS][8][80];
|
particle portalp[CHANNELS][8][80];
|
||||||
const particle emptyparticle;
|
const particle emptyparticle;
|
||||||
int wireless[CHANNELS][2];
|
int wireless[CHANNELS][2];
|
||||||
|
extern int portal_rx[8];
|
||||||
|
extern int portal_ry[8];
|
||||||
|
|
||||||
extern int wire_placed;
|
extern int wire_placed;
|
||||||
|
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
#include <element.h>
|
#include <element.h>
|
||||||
/*these are the count vaules of where the particle gets stored, depending on where it came from
|
/*these are the count values of where the particle gets stored, depending on where it came from
|
||||||
1 4 6
|
0 1 2
|
||||||
2 . 7
|
7 . 3
|
||||||
3 5 8
|
6 5 4
|
||||||
PRTO counts backwards, so that it will come out at the opposite place of where it came in
|
PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
|
||||||
8 5 3
|
|
||||||
7 . 2
|
|
||||||
6 4 1
|
|
||||||
PRTO does +/-1 to the count, so it doesn't jam as easily
|
PRTO does +/-1 to the count, so it doesn't jam as easily
|
||||||
*/
|
*/
|
||||||
|
int portal_rx[8] = {-1, 0, 1, 1, 1, 0,-1,-1};
|
||||||
|
int portal_ry[8] = {-1,-1,-1, 0, 1, 1, 1, 0};
|
||||||
|
|
||||||
int update_PRTI(UPDATE_FUNC_ARGS) {
|
int update_PRTI(UPDATE_FUNC_ARGS) {
|
||||||
int r, nnx, rx, ry, fe = 0;
|
int r, nnx, rx, ry, fe = 0;
|
||||||
int count =0;
|
int count =0;
|
||||||
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
|
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
|
||||||
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
|
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
|
||||||
else if (parts[i].tmp<0) parts[i].tmp = 0;
|
else if (parts[i].tmp<0) parts[i].tmp = 0;
|
||||||
for (rx=-1; rx<2; rx++)
|
for (count=0; count<8; count++)
|
||||||
for (ry=-1; ry<2; ry++)
|
{
|
||||||
|
rx = portal_rx[count];
|
||||||
|
ry = portal_ry[count];
|
||||||
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];
|
||||||
count ++;
|
|
||||||
if (!r)
|
if (!r)
|
||||||
fe = 1;
|
fe = 1;
|
||||||
if ((r>>8)>=NPART)
|
if ((r>>8)>=NPART)
|
||||||
@ -38,9 +39,9 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
|
|||||||
detach(r>>8);
|
detach(r>>8);
|
||||||
|
|
||||||
for ( nnx=0; nnx<80; nnx++)
|
for ( nnx=0; nnx<80; nnx++)
|
||||||
if (!portalp[parts[i].tmp][count-1][nnx].type)
|
if (!portalp[parts[i].tmp][count][nnx].type)
|
||||||
{
|
{
|
||||||
portalp[parts[i].tmp][count-1][nnx] = parts[r>>8];
|
portalp[parts[i].tmp][count][nnx] = parts[r>>8];
|
||||||
if ((r&0xFF)==PT_SPRK)
|
if ((r&0xFF)==PT_SPRK)
|
||||||
part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype);
|
part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype);
|
||||||
else
|
else
|
||||||
@ -49,6 +50,7 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fe) {
|
if (fe) {
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
#include <element.h>
|
#include <element.h>
|
||||||
/*these are the count vaules of where the particle gets stored, depending on where it came from
|
/*these are the count values of where the particle gets stored, depending on where it came from
|
||||||
1 4 6
|
0 1 2
|
||||||
2 . 7
|
7 . 3
|
||||||
3 5 8
|
6 5 4
|
||||||
PRTO counts backwards, so that it will come out at the opposite place of where it came in
|
PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
|
||||||
8 5 3
|
|
||||||
7 . 2
|
|
||||||
6 4 1
|
|
||||||
PRTO does +/-1 to the count, so it doesn't jam as easily
|
PRTO does +/-1 to the count, so it doesn't jam as easily
|
||||||
*/
|
*/
|
||||||
int update_PRTO(UPDATE_FUNC_ARGS) {
|
int update_PRTO(UPDATE_FUNC_ARGS) {
|
||||||
@ -15,12 +12,13 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
|
|||||||
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
|
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
|
||||||
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
|
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
|
||||||
else if (parts[i].tmp<0) parts[i].tmp = 0;
|
else if (parts[i].tmp<0) parts[i].tmp = 0;
|
||||||
for (rx=1; rx>-2; rx--)
|
for (count=0; count<8; count++)
|
||||||
for (ry=1; ry>-2; ry--)
|
{
|
||||||
|
rx = portal_rx[count];
|
||||||
|
ry = portal_ry[count];
|
||||||
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];
|
||||||
count ++;
|
|
||||||
if (!r)
|
if (!r)
|
||||||
fe = 1;
|
fe = 1;
|
||||||
if ((r>>8)>=NPART || r)
|
if ((r>>8)>=NPART || r)
|
||||||
@ -29,12 +27,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
|
|||||||
{
|
{
|
||||||
for ( nnx =0 ; nnx<80; nnx++)
|
for ( nnx =0 ; nnx<80; nnx++)
|
||||||
{
|
{
|
||||||
int randomness = count + rand()%3-1;//add -1,0,or 1 to count
|
int randomness = (count + rand()%3-1 + 4)%8;//add -1,0,or 1 to count
|
||||||
if (randomness<1)
|
if (portalp[parts[i].tmp][randomness][nnx].type==PT_SPRK)// TODO: make it look better, spark creation
|
||||||
randomness=1;
|
|
||||||
if (randomness>8)
|
|
||||||
randomness=8;
|
|
||||||
if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_SPRK)// TODO: make it look better, spark creation
|
|
||||||
{
|
{
|
||||||
create_part(-1,x+1,y,PT_SPRK);
|
create_part(-1,x+1,y,PT_SPRK);
|
||||||
create_part(-1,x+1,y+1,PT_SPRK);
|
create_part(-1,x+1,y+1,PT_SPRK);
|
||||||
@ -44,26 +38,27 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
|
|||||||
create_part(-1,x-1,y+1,PT_SPRK);
|
create_part(-1,x-1,y+1,PT_SPRK);
|
||||||
create_part(-1,x-1,y,PT_SPRK);
|
create_part(-1,x-1,y,PT_SPRK);
|
||||||
create_part(-1,x-1,y-1,PT_SPRK);
|
create_part(-1,x-1,y-1,PT_SPRK);
|
||||||
portalp[parts[i].tmp][randomness-1][nnx] = emptyparticle;
|
portalp[parts[i].tmp][randomness][nnx] = emptyparticle;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (portalp[parts[i].tmp][randomness-1][nnx].type)
|
else if (portalp[parts[i].tmp][randomness][nnx].type)
|
||||||
{
|
{
|
||||||
if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_STKM)
|
if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM)
|
||||||
player[27] = 0;
|
player[27] = 0;
|
||||||
if (portalp[parts[i].tmp][randomness-1][nnx].type==PT_STKM2)
|
if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2)
|
||||||
player2[27] = 0;
|
player2[27] = 0;
|
||||||
np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness-1][nnx].type);
|
np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness][nnx].type);
|
||||||
if (np<0) continue;
|
if (np<0) continue;
|
||||||
parts[np] = portalp[parts[i].tmp][randomness-1][nnx];
|
parts[np] = portalp[parts[i].tmp][randomness][nnx];
|
||||||
parts[np].x = x+rx;
|
parts[np].x = x+rx;
|
||||||
parts[np].y = y+ry;
|
parts[np].y = y+ry;
|
||||||
portalp[parts[i].tmp][randomness-1][nnx] = emptyparticle;
|
portalp[parts[i].tmp][randomness][nnx] = emptyparticle;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (fe) {
|
if (fe) {
|
||||||
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
|
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
|
||||||
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
|
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
|
||||||
|
23
src/powder.c
23
src/powder.c
@ -223,30 +223,19 @@ int try_move(int i, int x, int y, int nx, int ny)
|
|||||||
if ((r&0xFF)==PT_PRTI && (parts[i].type==PT_PHOT || parts[i].type==PT_NEUT))
|
if ((r&0xFF)==PT_PRTI && (parts[i].type==PT_PHOT || parts[i].type==PT_NEUT))
|
||||||
{
|
{
|
||||||
int nnx, count;
|
int nnx, count;
|
||||||
if (nx-x<0)
|
for (count=0; count<8; count++)
|
||||||
{
|
{
|
||||||
if (ny-y<0) count = 1;
|
if (isign(x-nx)==isign(portal_rx[count]) && isign(y-ny)==isign(portal_ry[count]))
|
||||||
else if (ny-y==0) count = 2;
|
break;
|
||||||
else count = 3;
|
|
||||||
}
|
|
||||||
else if (nx-x==0)
|
|
||||||
{
|
|
||||||
if (ny-y<0) count = 4;
|
|
||||||
else count = 5;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ny-y<0) count = 6;
|
|
||||||
else if (ny-y==0) count = 7;
|
|
||||||
else count = 8;
|
|
||||||
}
|
}
|
||||||
|
count = count%8;
|
||||||
parts[r>>8].tmp = (int)((parts[r>>8].temp-73.15f)/100+1);
|
parts[r>>8].tmp = (int)((parts[r>>8].temp-73.15f)/100+1);
|
||||||
if (parts[r>>8].tmp>=CHANNELS) parts[r>>8].tmp = CHANNELS-1;
|
if (parts[r>>8].tmp>=CHANNELS) parts[r>>8].tmp = CHANNELS-1;
|
||||||
else if (parts[r>>8].tmp<0) parts[r>>8].tmp = 0;
|
else if (parts[r>>8].tmp<0) parts[r>>8].tmp = 0;
|
||||||
for ( nnx=0; nnx<80; nnx++)
|
for ( nnx=0; nnx<80; nnx++)
|
||||||
if (!portalp[parts[r>>8].tmp][count-1][nnx].type)
|
if (!portalp[parts[r>>8].tmp][count][nnx].type)
|
||||||
{
|
{
|
||||||
portalp[parts[r>>8].tmp][count-1][nnx] = parts[i];
|
portalp[parts[r>>8].tmp][count][nnx] = parts[i];
|
||||||
parts[i].type=PT_NONE;
|
parts[i].type=PT_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user