add back element descriptions in some cpp files, fix minor TRON search problem. Also,

TPT-jacksonmj: Also fix bugs with energy particles that pass directly from PIPE to portal
This commit is contained in:
jacob1 2012-12-06 19:51:33 -05:00
parent a15372afbf
commit 226de5b6f8
3 changed files with 46 additions and 2 deletions

View File

@ -46,6 +46,14 @@ Element_PRTI::Element_PRTI()
Graphics = &Element_PRTI::graphics; Graphics = &Element_PRTI::graphics;
} }
/*these are the count values of where the particle gets stored, depending on where it came from
0 1 2
7 . 3
6 5 4
PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
PRTO does +/-1 to the count, so it doesn't jam as easily
*/
//#TPT-Directive ElementHeader Element_PRTI static int update(UPDATE_FUNC_ARGS) //#TPT-Directive ElementHeader Element_PRTI static int update(UPDATE_FUNC_ARGS)
int Element_PRTI::update(UPDATE_FUNC_ARGS) int Element_PRTI::update(UPDATE_FUNC_ARGS)
{ {

View File

@ -46,6 +46,14 @@ Element_PRTO::Element_PRTO()
Graphics = &Element_PRTO::graphics; Graphics = &Element_PRTO::graphics;
} }
/*these are the count values of where the particle gets stored, depending on where it came from
0 1 2
7 . 3
6 5 4
PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
PRTO does +/-1 to the count, so it doesn't jam as easily
*/
//#TPT-Directive ElementHeader Element_PRTO static int update(UPDATE_FUNC_ARGS) //#TPT-Directive ElementHeader Element_PRTO static int update(UPDATE_FUNC_ARGS)
int Element_PRTO::update(UPDATE_FUNC_ARGS) int Element_PRTO::update(UPDATE_FUNC_ARGS)
{ {
@ -114,6 +122,16 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
sim->fighters[(unsigned char)parts[np].tmp].spwn = 0; sim->fighters[(unsigned char)parts[np].tmp].spwn = 0;
sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1; sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1;
} }
if (sim->portalp[parts[i].tmp][randomness][nnx].vx == 0.0f && sim->portalp[parts[i].tmp][randomness][nnx].vy == 0.0f)
{
// particles that have passed from PIPE into PRTI have lost their velocity, so use the velocity of the newly created particle if the particle in the portal has no velocity
float tmp_vx = parts[np].vx;
float tmp_vy = parts[np].vy;
parts[np] = sim->portalp[parts[i].tmp][randomness][nnx];
parts[np].vx = tmp_vx;
parts[np].vy = tmp_vy;
}
else
parts[np] = sim->portalp[parts[i].tmp][randomness][nnx]; parts[np] = sim->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;

View File

@ -48,6 +48,24 @@ Element_TRON::Element_TRON()
Element_TRON::init_graphics(); Element_TRON::init_graphics();
} }
/* TRON element is meant to resemble a tron bike (or worm) moving around and trying to avoid obstacles itself.
* It has four direction each turn to choose from, 0 (left) 1 (up) 2 (right) 3 (down).
* Each turn has a small random chance to randomly turn one way (so it doesn't do the exact same thing in a large room)
* If the place it wants to move isn't a barrier, it will try and 'see' in front of itself to determine its safety.
* For now the tron can only see its own body length in pixels ahead of itself (and around corners)
* - - - - - - - - - -
* - - - - + - - - - -
* - - - + + + - - - -
* - - +<--+-->+ - - -
* - +<----+---->+ - -
* - - - - H - - - - -
* Where H is the head with tail length 4, it checks the + area to see if it can hit any of the edges, then it is called safe, or picks the biggest area if none safe.
* .tmp bit values: 1st head, 2nd no tail growth, 3rd wait flag, 4th Nodie, 5th Dying, 6th & 7th is direction, 8th - 16th hue, 17th Norandom
* .tmp2 is tail length (gets longer every few hundred frames)
* .life is the timer that kills the end of the tail (the head uses life for how often it grows longer)
* .ctype Contains the colour, lost on save, regenerated using hue tmp (bits 7 - 16)
*/
#define TRON_HEAD 1 #define TRON_HEAD 1
#define TRON_NOGROW 2 #define TRON_NOGROW 2
#define TRON_WAIT 4 //it was just created, so WAIT a frame #define TRON_WAIT 4 //it was just created, so WAIT a frame
@ -205,7 +223,7 @@ int Element_TRON::trymovetron(Simulation * sim, int x, int y, int dir, int i, in
rx += tron_rx[dir]; rx += tron_rx[dir];
ry += tron_ry[dir]; ry += tron_ry[dir];
r = sim->pmap[ry][rx]; r = sim->pmap[ry][rx];
if (canmovetron(sim, r, k) && !sim->bmap[(ry)/CELL][(rx)/CELL] && ry > CELL && rx > CELL && ry < YRES-CELL && rx < XRES-CELL) if (canmovetron(sim, r, k-1) && !sim->bmap[(ry)/CELL][(rx)/CELL] && ry > CELL && rx > CELL && ry < YRES-CELL && rx < XRES-CELL)
{ {
count++; count++;
for (tx = rx - tron_ry[dir] , ty = ry - tron_rx[dir], j=1; abs(tx-rx) < (len-k) && abs(ty-ry) < (len-k); tx-=tron_ry[dir],ty-=tron_rx[dir],j++) for (tx = rx - tron_ry[dir] , ty = ry - tron_rx[dir], j=1; abs(tx-rx) < (len-k) && abs(ty-ry) < (len-k); tx-=tron_ry[dir],ty-=tron_rx[dir],j++)