diff options
| author | jacob1 <jfu614@gmail.com> | 2012-12-06 23:42:46 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2012-12-06 23:42:46 (GMT) |
| commit | a15372afbfce1dcb500541fa36ee0724023f1ac3 (patch) | |
| tree | 17019f44d7289956855208b61d4112ec59d0e76e /src/simulation/elements | |
| parent | 2881eeb1b3f9cf3cf1ab523c7ccf99f0bd65199c (diff) | |
| download | powder-a15372afbfce1dcb500541fa36ee0724023f1ac3.zip powder-a15372afbfce1dcb500541fa36ee0724023f1ac3.tar.gz | |
TRON_NORANDOM flag
Diffstat (limited to 'src/simulation/elements')
| -rw-r--r-- | src/simulation/elements/TRON.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/simulation/elements/TRON.cpp b/src/simulation/elements/TRON.cpp index e77e695..42ebf86 100644 --- a/src/simulation/elements/TRON.cpp +++ b/src/simulation/elements/TRON.cpp @@ -53,6 +53,7 @@ Element_TRON::Element_TRON() #define TRON_WAIT 4 //it was just created, so WAIT a frame #define TRON_NODIE 8 #define TRON_DEATH 16 //Crashed, now dying +#define TRON_NORANDOM 65536 int tron_rx[4] = {-1, 0, 1, 0}; int tron_ry[4] = { 0,-1, 0, 1}; unsigned int tron_colours[32]; @@ -86,7 +87,7 @@ int Element_TRON::update(UPDATE_FUNC_ARGS) //random turn int random = rand()%340; - if (random==1 || random==3) + if ((random==1 || random==3) && !(parts[i].tmp & TRON_NORANDOM)) { //randomly turn left(3) or right(1) direction = (direction + random)%4; @@ -97,7 +98,12 @@ int Element_TRON::update(UPDATE_FUNC_ARGS) firstdircheck = Element_TRON::trymovetron(sim,x,y,direction,i,parts[i].tmp2); if (firstdircheck < parts[i].tmp2) { - if (originaldir != direction) //if we just tried a random turn, don't pick random again + if (parts[i].tmp & TRON_NORANDOM) + { + seconddir = (direction + 1)%4; + lastdir = (direction + 3)%4; + } + else if (originaldir != direction) //if we just tried a random turn, don't pick random again { seconddir = originaldir; lastdir = (direction + 2)%4; @@ -177,7 +183,7 @@ int Element_TRON::new_tronhead(Simulation * sim, int x, int y, int i, int direct sim->parts[i].life = 5; } //give new head our properties - sim->parts[np].tmp = 1 | direction<<5 | sim->parts[i].tmp&(TRON_NOGROW|TRON_NODIE) | (sim->parts[i].tmp&0xF800); + sim->parts[np].tmp = 1 | direction<<5 | sim->parts[i].tmp&(TRON_NOGROW|TRON_NODIE|TRON_NORANDOM) | (sim->parts[i].tmp&0xF800); if (np > i) sim->parts[np].tmp |= TRON_WAIT; |
