Add size support for particle

scene_man
En Yi 2023-11-01 22:36:44 +08:00
parent edf78412dc
commit dc0fcc381c
1 changed files with 14 additions and 2 deletions

View File

@ -54,6 +54,8 @@ void add_particle_emitter(ParticleSystem_t* system, const ParticleEmitter_t* in_
emitter->particles[i].position = emitter->position; emitter->particles[i].position = emitter->position;
emitter->particles[i].rotation = angle; emitter->particles[i].rotation = angle;
emitter->particles[i].angular_vel = -10 + 20 * (float)rand() / (float)RAND_MAX; emitter->particles[i].angular_vel = -10 + 20 * (float)rand() / (float)RAND_MAX;
emitter->particles[i].size = 10 + 20 * (float)rand() / (float)RAND_MAX;
;
} }
} }
void update_particle_system(ParticleSystem_t* system) void update_particle_system(ParticleSystem_t* system)
@ -117,9 +119,19 @@ void draw_particle_system(ParticleSystem_t* system)
{ {
if (part->alive) if (part->alive)
{ {
if (emitter->tex == NULL) if (emitter->tex == NULL || emitter->tex->width == 0)
{ {
DrawCircleV(part->position, 5, BLACK); Rectangle rect = {
.x = part->position.x,
.y = part->position.y,
.width = part->size,
.height = part->size
};
Vector2 origin = (Vector2){
part->size / 2,
part->size / 2
};
DrawRectanglePro(rect, origin, part->rotation, BLACK);
} }
else else
{ {