79 lines
1.9 KiB
C++
79 lines
1.9 KiB
C++
#include "particles.h"
|
|
|
|
#include <azur/azur.h>
|
|
#include <azur/gint/render.h>
|
|
|
|
#include <cstdint>
|
|
#include <stdlib.h>
|
|
|
|
extern bopti_image_t img_fill_circ_0;
|
|
/*
|
|
extern bopti_image_t img_fill_circ_1;
|
|
extern bopti_image_t img_fill_circ_2;
|
|
extern bopti_image_t img_fill_circ_3;
|
|
extern bopti_image_t img_fill_circ_4;
|
|
extern bopti_image_t img_fill_circ_5;
|
|
*/
|
|
|
|
Particle::Particle( uint16_t lx, uint16_t ly )
|
|
{
|
|
x = (float) lx;
|
|
y = (float) ly;
|
|
|
|
sx = (float) ((((float) (rand() % 11))-5.0f)/4.0f);
|
|
sy = (float) ((((float) (rand() % 11))-5.0f)/4.0f);
|
|
|
|
age = rand() % 3;
|
|
maxage = 20 + rand() % 20;
|
|
|
|
size = 3 + (rand() % 5);
|
|
|
|
toberemoved = false;
|
|
}
|
|
|
|
Particle::~Particle()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
void Particle::Update( float dt )
|
|
{
|
|
x = x + sx*dt/12000;
|
|
y = y + sy*dt/12000;
|
|
age += dt/10000;
|
|
sx *= 0.85;
|
|
sy *= 0.85;
|
|
|
|
if(age > maxage) size*=0.85;
|
|
if(size<1.0f) toberemoved=true;
|
|
}
|
|
|
|
void Particle::Render( )
|
|
{
|
|
uint8_t dximg = ((uint16_t) size-1)*15;
|
|
|
|
uint16_t px = (uint16_t) x;
|
|
uint16_t py = (uint16_t) y;
|
|
|
|
/* if (age>25) azrp_subimage( px-7, py-7, &img_fill_circ_5, dximg, 0, 15, 15, DIMAGE_NONE );
|
|
else if (age>20) azrp_subimage( px-7, py-7, &img_fill_circ_4, dximg, 0, 15, 15, DIMAGE_NONE );
|
|
else if (age>15) azrp_subimage( px-7, py-7, &img_fill_circ_3, dximg, 0, 15, 15, DIMAGE_NONE );
|
|
else if (age>10) azrp_subimage( px-7, py-7, &img_fill_circ_2, dximg, 0, 15, 15, DIMAGE_NONE );
|
|
else if (age>5) azrp_subimage( px-7, py-7, &img_fill_circ_1, dximg, 0, 15, 15, DIMAGE_NONE );
|
|
else azrp_subimage( px-7, py-7, &img_fill_circ_0, dximg, 0, 15, 15, DIMAGE_NONE );
|
|
*/
|
|
|
|
int color;
|
|
|
|
if (age>30) color=0x526A;
|
|
else if (age>25) color=0x71D6;
|
|
else if (age>20) color=0xF80D;
|
|
else if (age>15) color=0xFB80;
|
|
else if (age>10) color=0xFFE0;
|
|
else color=0xFFFF;
|
|
|
|
azrp_subimage_p8_dye( px-7, py-7, &img_fill_circ_0, dximg, 0, 15, 15, IMAGE_DYE, color );
|
|
}
|
|
|