Permalink
Browse files

Skylark: make GRAV prettier

  • Loading branch information...
jacob1 committed Apr 12, 2017
1 parent d3f0896 commit cf03731dc35c2d3586b39a4ef841103759640896
Showing with 29 additions and 3 deletions.
  1. +29 −3 src/simulation/elements/GRAV.cpp
@@ -1,4 +1,5 @@
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_GRAV PT_GRAV 102
Element_GRAV::Element_GRAV()
{
@@ -30,7 +31,7 @@ Element_GRAV::Element_GRAV()
HeatConduct = 70;
Description = "Very light dust. Changes colour based on velocity.";
Properties = TYPE_PART;
Properties = TYPE_PART | PROP_LIFE_DEC;
LowPressure = IPL;
LowPressureTransition = NT;
@@ -41,12 +42,24 @@ Element_GRAV::Element_GRAV()
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = NULL;
Update = &Element_GRAV::update;
Graphics = &Element_GRAV::graphics;
}
//#TPT-Directive ElementHeader Element_GRAV static int update(UPDATE_FUNC_ARGS)
int Element_GRAV::update(UPDATE_FUNC_ARGS)
{
if (parts[i].vx*parts[i].vx + parts[i].vy*parts[i].vy >= 0.1f && (rand() % 512) == 0)
{
if (!parts[i].life)
parts[i].life = 48;
}
return 0;
}
//#TPT-Directive ElementHeader Element_GRAV static int graphics(GRAPHICS_FUNC_ARGS)
int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS)
{
int GRAV_R, GRAV_B, GRAV_G, GRAV_R2, GRAV_B2, GRAV_G2;
@@ -87,6 +100,19 @@ int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS)
*colg -= (cpart->vy)*GRAV_G2;
*colb -= (cpart->vy)*GRAV_B2;
}
if (cpart->life)
{
*pixel_mode = FIRE_ADD | PMODE_ADD | PMODE_GLOW | PMODE_FLARE;
*firer = std::min(*colr * 3, 255);
*fireg = std::min(*colg * 3, 255);
*fireb = std::min(*colb * 3, 255);
*firea = (cpart->life+15)*4;
*cola = (cpart->life+15)*4;
}
else
*pixel_mode = PMODE_ADD;
return 0;
}

0 comments on commit cf03731

Please sign in to comment.