Alterations to TRON and fancy effects

This commit is contained in:
Simon Robertshaw 2012-04-17 22:38:27 +01:00
parent a7e1774d41
commit ffa5ccb666
4 changed files with 56 additions and 16 deletions

View File

@ -325,6 +325,7 @@ int graphics_WIRE(GRAPHICS_FUNC_ARGS);
int graphics_ACEL(GRAPHICS_FUNC_ARGS);
int graphics_DCEL(GRAPHICS_FUNC_ARGS);
int graphics_GEL(GRAPHICS_FUNC_ARGS);
int graphics_TRON(GRAPHICS_FUNC_ARGS);
#define UPDATE_FUNC_ARGS int i, int x, int y, int surround_space, int nt
// to call another update function with same arguments:

View File

@ -157,7 +157,7 @@ part_type ptypes[PT_NUM] =
{"IGNC", PIXPACK(0xC0B050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Ignition cord.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE | PROP_SPARKSETTLE | PROP_LIFE_KILL, &update_IGNT, NULL},
{"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL, NULL},
{"GEL", PIXPACK(0xFF9900), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 35, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Gel. A liquid with variable viscosity and heat conductivity", ST_LIQUID, TYPE_LIQUID|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_GEL, &graphics_GEL},
{"TRON", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, 0.0f, 40, "An automaton tron snake thing", ST_NONE, TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL, &update_TRON, NULL},
{"TRON", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, 0.0f, 40, "An automaton tron snake thing", ST_NONE, TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL, &update_TRON, &graphics_TRON},
/*FREE*/{"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},
/*FREE*/{"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},
/*FREE*/{"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},

View File

@ -12,14 +12,16 @@
* - +<----+---->+ - -
* - - - - 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: 0 tail , 1 head , 2 no tail growth , 4-8 is direction , 16 is wait flag
* .tmp bit values: 1st head, 2nd no tail growth, 3rd wait flag, 4th Nodie, 5th Dying, 6th & 7th is direction, 8th - 16th hue
* .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 16 //it was just created, so WAIT a frame
#define TRON_NODIE 32
#define TRON_WAIT 4 //it was just created, so WAIT a frame
#define TRON_NODIE 8
#define TRON_DEATH 16 //Crashed, now dying
int tron_rx[4] = {-1, 0, 1, 0};
int tron_ry[4] = { 0,-1, 0, 1};
int new_tronhead(int x, int y, int i, int direction)
@ -33,13 +35,13 @@ int new_tronhead(int x, int y, int i, int direction)
parts[i].life = 5;
}
//give new head our properties
parts[np].tmp = 1 | direction<<2 | parts[i].tmp&(TRON_NOGROW|TRON_NODIE);
parts[np].tmp = 1 | direction<<5 | parts[i].tmp&(TRON_NOGROW|TRON_NODIE) | (parts[i].tmp&0xF800);
if (np > i)
parts[np].tmp |= TRON_WAIT;
parts[np].ctype = parts[i].ctype;
parts[np].tmp2 = parts[i].tmp2;
parts[np].life = parts[i].life + 2;
parts[np].dcolour = parts[i].dcolour;
return 1;
}
int trymovetron(int x, int y, int dir, int i, int len)
@ -88,15 +90,23 @@ int trymovetron(int x, int y, int dir, int i, int len)
}
int update_TRON(UPDATE_FUNC_ARGS) {
int r, rx, ry, np;
if(!parts[i].ctype)
{
int r, g, b;
int hue = (parts[i].tmp&0xF800)>>7;
HSV_to_RGB(hue,255,255,&r,&g,&b);
parts[i].ctype = r<<16 | g<<8 | b;
//Use photon-like wavelength?
}
if (parts[i].tmp&TRON_WAIT)
{
parts[i].tmp -= TRON_WAIT;
parts[i].tmp &= ~TRON_WAIT;
return 0;
}
if (parts[i].tmp&TRON_HEAD)
{
int firstdircheck = 0,seconddir,seconddircheck = 0,lastdir,lastdircheck = 0;
int direction = (parts[i].tmp>>2 & 0x3);
int direction = (parts[i].tmp>>5 & 0x3);
int originaldir = direction;
//random turn
@ -133,20 +143,52 @@ int update_TRON(UPDATE_FUNC_ARGS) {
//now try making new head, even if it fails
if (new_tronhead(x + tron_rx[direction],y + tron_ry[direction],i,direction) == -1)
{
//ohgod crash, <sparkle effect start here>
//ohgod crash
parts[i].tmp |= TRON_DEATH;
//trigger tail death for TRON_NODIE, or is that mode even needed? just set a high tail length(but it still won't start dying when it crashes)
}
//set own life and clear .tmp (it dies if it can't move anyway)
parts[i].life = parts[i].tmp2;
parts[i].tmp = 0;
parts[i].tmp &= parts[i].tmp&0xF810;
}
else // fade tail deco, or prevent tail from dieing
{
if (parts[i].tmp&TRON_NODIE)
parts[i].life++;
parts[i].dcolour = clamp_flt((float)parts[i].life/(float)parts[i].tmp2,0,1.0f) << 24 | parts[i].dcolour&0x00FFFFFF;
//parts[i].dcolour = clamp_flt((float)parts[i].life/(float)parts[i].tmp2,0,1.0f) << 24 | parts[i].dcolour&0x00FFFFFF;
}
return 0;
}
int graphics_TRON(GRAPHICS_FUNC_ARGS) {
if(cpart->tmp & TRON_HEAD)
*pixel_mode |= PMODE_GLOW;
if(cpart->ctype)
{
*colr = (cpart->ctype & 0xFF0000)>>16;
*colg = (cpart->ctype & 0x00FF00)>>8;
*colb = (cpart->ctype & 0x0000FF);
}
else
{
*colr = 255;
*colg = 255;
*colb = 255;
}
if(cpart->tmp & TRON_DEATH)
{
*pixel_mode |= FIRE_ADD | PMODE_FLARE;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
*firea = 255;
}
if(cpart->life < cpart->tmp2)
{
*pixel_mode |= PMODE_BLEND;
*pixel_mode &= ~PMODE_FLAT;
*cola = (int)((((float)cpart->life)/((float)cpart->tmp2))*255.0f);
}
return 0;
}

View File

@ -931,12 +931,9 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
}
if (t==PT_TRON)
{
int rr,rg,rb;
int randhue = rand()%360;
int randomdir = rand()%4;
HSV_to_RGB(randhue,255,255,&rr,&rg,&rb);
parts[i].dcolour = 255<<24 | rr<<16 | rg<<8 | rb;
parts[i].tmp = 1|(randomdir<<2);//set as a head and a direction
parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction
parts[i].tmp2 = 4;//tail
parts[i].life = 5;
}