summaryrefslogtreecommitdiff
path: root/src/simulation/elements
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2012-12-07 00:51:33 (GMT)
committer jacob1 <jfu614@gmail.com>2012-12-07 00:51:33 (GMT)
commit226de5b6f88c95a4f76675be067de1af5de13902 (patch)
tree30a4437815ac04f762c1e926a9eaec337835067c /src/simulation/elements
parenta15372afbfce1dcb500541fa36ee0724023f1ac3 (diff)
downloadpowder-226de5b6f88c95a4f76675be067de1af5de13902.zip
powder-226de5b6f88c95a4f76675be067de1af5de13902.tar.gz
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
Diffstat (limited to 'src/simulation/elements')
-rw-r--r--src/simulation/elements/PRTI.cpp8
-rw-r--r--src/simulation/elements/PRTO.cpp20
-rw-r--r--src/simulation/elements/TRON.cpp20
3 files changed, 46 insertions, 2 deletions
diff --git a/src/simulation/elements/PRTI.cpp b/src/simulation/elements/PRTI.cpp
index 8383d90..e2daded 100644
--- a/src/simulation/elements/PRTI.cpp
+++ b/src/simulation/elements/PRTI.cpp
@@ -46,6 +46,14 @@ Element_PRTI::Element_PRTI()
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)
int Element_PRTI::update(UPDATE_FUNC_ARGS)
{
diff --git a/src/simulation/elements/PRTO.cpp b/src/simulation/elements/PRTO.cpp
index b4554ec..4a51657 100644
--- a/src/simulation/elements/PRTO.cpp
+++ b/src/simulation/elements/PRTO.cpp
@@ -46,6 +46,14 @@ Element_PRTO::Element_PRTO()
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)
int Element_PRTO::update(UPDATE_FUNC_ARGS)
{
@@ -114,7 +122,17 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
sim->fighters[(unsigned char)parts[np].tmp].spwn = 0;
sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1;
}
- parts[np] = sim->portalp[parts[i].tmp][randomness][nnx];
+ 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].x = x+rx;
parts[np].y = y+ry;
sim->portalp[parts[i].tmp][randomness][nnx] = sim->emptyparticle;
diff --git a/src/simulation/elements/TRON.cpp b/src/simulation/elements/TRON.cpp
index 42ebf86..c995733 100644
--- a/src/simulation/elements/TRON.cpp
+++ b/src/simulation/elements/TRON.cpp
@@ -48,6 +48,24 @@ Element_TRON::Element_TRON()
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_NOGROW 2
#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];
ry += tron_ry[dir];
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++;
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++)