adding a ccol particule effect on the player

This commit is contained in:
Clément Le Bihan
2020-05-03 03:09:54 +02:00
parent 9f1f9fa6a4
commit d5c0b3dd07
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -39,6 +39,6 @@
<xp_component xp="20"/>
<health_component max_health="25"/>
<player_component fight_rate="5%" />
<particule_component type="1" nb_particules_max="25" lifetime="120" />
<particule_component type="1" nb_particules_max="15" lifetime="60" texture="stone" />
</gc_entity>
</gc_entities>
+1 -1
View File
@@ -50,7 +50,7 @@ component;
}
cmp->type = xml_getintprop(n, "type");
cmp->nb_max_particules = xml_getintprop(n, "nb_particules_max");
cmp->texture = NULL;
cmp->texture = scene->get_data(scene, "sprite", xml_getproperty(n, "texture"));
cmp->lifetime = xml_getintprop(n, "lifetime");
cmp->particules = malloc(sizeof(struct particule_component) * \
(cmp->nb_max_particules + 1));
+3 -2
View File
@@ -23,7 +23,7 @@ void *texture, gc_vector2 pos)
particule->sprite->texture = texture;
particule->sprite->pos = pos;
particule->sprite->rect = (gc_int_rect){16, 16,0,0};
particule->sprite->scale = (gc_vector2){1, 1};
particule->sprite->scale = (gc_vector2){0.2, 0.2};
}
void particule_draw(gc_engine *engine, void *system, \
@@ -54,10 +54,11 @@ float dtime)
if (!ml || !tc || !cmp)
return;
//ml->tile->texture
for (int i = 0; i < cmp->nb_max_particules; i++) {
cmp->particules[i].lifetime -= (cmp->particules[i].lifetime) ? 1 : 0;
if (!cmp->particules[i].lifetime) {
create_particule(&cmp->particules[i], cmp->lifetime, ml->tile->texture, tc->position);
create_particule(&cmp->particules[i], cmp->lifetime, cmp->texture, tc->position);
}
}
particule_draw(engine, system, entity, dtime);