Improvements to Wire

This commit is contained in:
Simon Robertshaw 2011-08-08 14:57:32 +01:00
parent dd2d06425e
commit 9b9d628374
3 changed files with 39 additions and 24 deletions

View File

@ -936,6 +936,8 @@ particle portalp[CHANNELS][8][80];
const particle emptyparticle; const particle emptyparticle;
int wireless[CHANNELS][2]; int wireless[CHANNELS][2];
extern int ISWIRE;
extern int gravwl_timeout; extern int gravwl_timeout;
extern float player[28]; extern float player[28];

View File

@ -2,7 +2,6 @@
int update_WIRE(UPDATE_FUNC_ARGS) { int update_WIRE(UPDATE_FUNC_ARGS) {
int s,r,rx,ry,count; int s,r,rx,ry,count;
s=pmap[y][x];
/* /*
0: wire 0: wire
1: spark head 1: spark head
@ -10,23 +9,32 @@ int update_WIRE(UPDATE_FUNC_ARGS) {
tmp is previous state, ctype is current state tmp is previous state, ctype is current state
*/ */
//parts[s>>8].tmp=parts[s>>8].ctype; //parts[i].tmp=parts[i].ctype;
parts[s>>8].ctype=0; parts[i].ctype=0;
if(parts[s>>8].tmp==1){parts[s>>8].ctype=2; return 0;} if(parts[i].tmp==1)
if(parts[s>>8].tmp==2){parts[s>>8].ctype=0; return 0;} {
parts[i].ctype=2;
}
if(parts[i].tmp==2)
{
parts[i].ctype=0;
}
count=0; count=0;
for(rx=-1; rx<2; rx++) for(rx=-1; rx<2; rx++)
for(ry=-1; ry<2; ry++) for(ry=-1; ry<2; ry++)
{ {
if(x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && pmap[y+ry][x+rx] && (rx!=0 || ry!=0) && (pmap[y+ry][x+rx]&0xFF)!=0xFF) 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&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN){parts[s>>8].ctype=1; parts[r>>8].life=0; return 0;} if ((r>>8)>=NPART || !r)
if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1){count++;} continue;
if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN){parts[i].ctype=1; parts[r>>8].life=0; return 0;}
else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){create_part(-1, x+rx, y+ry, PT_SPRK);}
else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;}
} }
} }
if(count==1 || count==2) if(count==1 || count==2)
parts[s>>8].ctype=1; parts[i].ctype=1;
return 0; return 0;
} }

View File

@ -7,6 +7,8 @@
int gravwl_timeout = 0; int gravwl_timeout = 0;
int ISWIRE = 0;
float player[28]; //[0] is a command cell, [3]-[18] are legs positions, [19]-[26] are accelerations, [27] shows if player was spawned float player[28]; //[0] is a command cell, [3]-[18] are legs positions, [19]-[26] are accelerations, [27] shows if player was spawned
float player2[28]; float player2[28];
@ -709,11 +711,6 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
if (t==PT_SPRK) if (t==PT_SPRK)
{ {
if((pmap[y][x]>>8)==PT_WIRE)
{
parts[pmap[y][x]>>8].ctype=1;
return -1;
}
if ((pmap[y][x]>>8)>=NPART || !((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS))) if ((pmap[y][x]>>8)>=NPART || !((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS)))
return -1; return -1;
if (parts[pmap[y][x]>>8].life!=0) if (parts[pmap[y][x]>>8].life!=0)
@ -1472,6 +1469,9 @@ void update_particles_i(pixel *vid, int start, int inc)
} }
} }
//wire! //wire!
if(ISWIRE == 1)
{
ISWIRE = 0;
for (nx=0; nx<XRES; nx++) for (nx=0; nx<XRES; nx++)
for (ny=0; ny<YRES; ny++) for (ny=0; ny<YRES; ny++)
{ {
@ -1480,6 +1480,7 @@ void update_particles_i(pixel *vid, int start, int inc)
continue; continue;
parts[r>>8].tmp=parts[r>>8].ctype; parts[r>>8].tmp=parts[r>>8].ctype;
} }
}
//game of life! //game of life!
if (ISGOL==1&&++CGOL>=GSPEED)//GSPEED is frames per generation if (ISGOL==1&&++CGOL>=GSPEED)//GSPEED is frames per generation
{ {
@ -1887,6 +1888,10 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].temp = restrict_flt(parts[i].temp-50.0f, MIN_TEMP, MAX_TEMP); parts[i].temp = restrict_flt(parts[i].temp-50.0f, MIN_TEMP, MAX_TEMP);
ISGOL=1;//means there is a life particle on screen ISGOL=1;//means there is a life particle on screen
} }
if (t==PT_WIRE)
{
ISWIRE = 1;
}
//spark updates from walls //spark updates from walls
if ((ptypes[t].properties&PROP_CONDUCTS) || t==PT_SPRK) if ((ptypes[t].properties&PROP_CONDUCTS) || t==PT_SPRK)
{ {