summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2012-04-27 16:59:24 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2012-04-27 17:09:54 (GMT)
commit6101c04ff9ee55e2be9a100a76a65ed1559ca24a (patch)
tree2f36da1315ed8cf3f51d2582641bce5b1ae45d48 /src/elements
parentc8a1524d6bf6bd9e249b31dcf699b589ae50cbba (diff)
downloadpowder-6101c04ff9ee55e2be9a100a76a65ed1559ca24a.zip
powder-6101c04ff9ee55e2be9a100a76a65ed1559ca24a.tar.gz
Use an array instead of ctype to cache tron colour
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/tron.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/elements/tron.c b/src/elements/tron.c
index df8fbe3..00d2e9e 100644
--- a/src/elements/tron.c
+++ b/src/elements/tron.c
@@ -24,6 +24,7 @@
#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];
int new_tronhead(int x, int y, int i, int direction)
{
int np = create_part(-1, x , y ,PT_TRON);
@@ -90,14 +91,6 @@ 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;
@@ -162,20 +155,12 @@ int update_TRON(UPDATE_FUNC_ARGS) {
}
int graphics_TRON(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;
@@ -191,4 +176,15 @@ int graphics_TRON(GRAPHICS_FUNC_ARGS) {
*cola = (int)((((float)cpart->life)/((float)cpart->tmp2))*255.0f);
}
return 0;
-} \ No newline at end of file
+}
+
+void 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;
+ }
+}