summaryrefslogtreecommitdiff
path: root/src/simulation/elements/TRON.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulation/elements/TRON.cpp')
-rw-r--r--src/simulation/elements/TRON.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/simulation/elements/TRON.cpp b/src/simulation/elements/TRON.cpp
index a449bc6..cb5f865 100644
--- a/src/simulation/elements/TRON.cpp
+++ b/src/simulation/elements/TRON.cpp
@@ -44,6 +44,8 @@ Element_TRON::Element_TRON()
Update = &Element_TRON::update;
Graphics = &Element_TRON::graphics;
+
+ Element_TRON::init_graphics();
}
#define TRON_HEAD 1
@@ -53,19 +55,24 @@ Element_TRON::Element_TRON()
#define TRON_DEATH 16 //Crashed, now dying
int tron_rx[4] = {-1, 0, 1, 0};
int tron_ry[4] = { 0,-1, 0, 1};
+unsigned int tron_colours[32];
+
+//#TPT-Directive ElementHeader Element_TRON static void init_graphics()
+void Element_TRON::init_graphics()
+{
+ int i;
+ int r, g, b;
+ for (i=0; i<32; i++)
+ {
+ HSV_to_RGB(i<<4,255,255,&r,&g,&b);
+ tron_colours[i] = r<<16 | g<<8 | b;
+ }
+}
//#TPT-Directive ElementHeader Element_TRON static int update(UPDATE_FUNC_ARGS)
int Element_TRON::update(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;
@@ -134,20 +141,12 @@ int Element_TRON::update(UPDATE_FUNC_ARGS)
//#TPT-Directive ElementHeader Element_TRON static int graphics(GRAPHICS_FUNC_ARGS)
int Element_TRON::graphics(GRAPHICS_FUNC_ARGS)
{
+ unsigned int col = tron_colours[(cpart->tmp&0xF800)>>11];
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;
- }
+ *colr = (col & 0xFF0000)>>16;
+ *colg = (col & 0x00FF00)>>8;
+ *colb = (col & 0x0000FF);
if(cpart->tmp & TRON_DEATH)
{
*pixel_mode |= FIRE_ADD | PMODE_FLARE;
@@ -233,4 +232,4 @@ int Element_TRON::trymovetron(Simulation * sim, int x, int y, int dir, int i, in
return count;
}
-Element_TRON::~Element_TRON() {} \ No newline at end of file
+Element_TRON::~Element_TRON() {}