#include "../config.h" #include "particles.h" #include #include #include #include #include extern bopti_image_t img_fill_circ; extern bopti_image_t img_firstboom; Particle::Particle( uint16_t lx, uint16_t ly, uint8_t id ) { x = libnum::num( lx ); y = libnum::num( ly ); sx = (libnum::num( rand() % 21 - 10 )) / 8; sy = (libnum::num( rand() % 21 - 10 )) / 8; ID=id; age = 0; if (ID==0) incage = libnum::num(1); else incage = libnum::num( 1+ rand() % 2); maxage = libnum::num( 30 + ( rand() % 25 ) ); size = libnum::num( 3 + ( rand() % 5 ) ); toberemoved = false; } Particle::~Particle() { } void Particle::Update( float dt ) { libnum::num a = libnum::num( dt / 12000.0f ); x += sx * a; y += sy * a; //age += libnum::num( dt / 12000.0f ); age += libnum::num( dt / 12000.0f ) * incage; sx *= libnum::num( 0.90 ); sy *= libnum::num( 0.90 ); if( age > maxage ) size *= libnum::num( 0.85 ); if( size < libnum::num( 1.0f ) ) toberemoved = true; } void Particle::Render( ) { uint8_t dximg = (int) ( size - libnum::num( 1 ) ) * 15; uint8_t sz = (int) size; uint16_t px = (int) x; uint16_t py = (int) y; if (ID==0 && age<5) { azrp_image_p8( px-12, py-12, &img_firstboom, DIMAGE_NONE ); return; } if (age>=10) { int color; if ( age > 40 ) color = 0x526A; // Dark Purple Gray-ish else if ( age > 35 ) color = 0x71D6; // Red Brown -ish else if ( age > 30 ) color = 0xF80D; // Dark Red else if ( age > 25 ) color = 0xFB80; // Red else if ( age > 30 ) color = 0xFFE0; // Yellow else color = 0xFFFF; // White azrp_subimage_p8_dye( px-sz, py-sz, &img_fill_circ, dximg+7-sz, 7-sz, sz*2, sz*2, IMAGE_DYE, color ); } }