mirror of
https://github.com/zoriya/ForecastingVillage.git
synced 2026-06-03 02:51:45 +00:00
modifying the map and particules works better now
This commit is contained in:
@@ -9,9 +9,12 @@
|
||||
#define MY_RPG_PARTICULE_SYSTEM_H
|
||||
|
||||
#include "engine.h"
|
||||
#include "components/particule_component.h"
|
||||
|
||||
void particule_update_entity(gc_engine *engine, void *system, \
|
||||
gc_entity *entity, float dt);
|
||||
void create_particule(struct particule *particule, int lifetime, \
|
||||
void *texture, gc_vector2 pos);
|
||||
|
||||
extern const struct gc_system particule_system;
|
||||
|
||||
|
||||
@@ -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="5" lifetime="60" />
|
||||
<particule_component type="1" nb_particules_max="25" lifetime="120" />
|
||||
</gc_entity>
|
||||
</gc_entities>
|
||||
|
||||
@@ -1304,8 +1304,8 @@
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="10" />
|
||||
<row height="10" />
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="40" />
|
||||
@@ -1376,8 +1376,8 @@
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="10" />
|
||||
<row height="10" />
|
||||
<row height="0" />
|
||||
<row height="0" />
|
||||
<row height="60" />
|
||||
@@ -6263,7 +6263,7 @@
|
||||
<tile x="17" y="45" texture="water_top_right" rotation="2" solid="true"/>
|
||||
<tile x="17" y="46" texture="water" rotation="0" solid="true"/>
|
||||
<tile x="17" y="47" texture="water" rotation="0" solid="true"/>
|
||||
<tile x="17" y="48" texture="npc_interact" rotation="0" />
|
||||
<tile x="17" y="48" texture="npc_interact" rotation="2" />
|
||||
<tile x="17" y="49" texture="dirt" rotation="0" solid="true"/>
|
||||
<tile x="17" y="50" texture="water" rotation="0" solid="true"/>
|
||||
<tile x="17" y="51" texture="water" rotation="0" solid="true"/>
|
||||
@@ -7621,7 +7621,7 @@
|
||||
<tile x="37" y="23" texture="dirt" rotation="0" />
|
||||
<tile x="37" y="24" texture="dirt" rotation="0" />
|
||||
<tile x="37" y="25" texture="dirt" rotation="0" />
|
||||
<tile x="37" y="26" texture="dirt" rotation="0" />
|
||||
<tile x="37" y="26" texture="npc_interact" rotation="2" />
|
||||
<tile x="37" y="27" texture="dirt" rotation="0" />
|
||||
<tile x="37" y="28" texture="dirt" rotation="0" />
|
||||
<tile x="37" y="29" texture="dirt" rotation="0" />
|
||||
@@ -7958,7 +7958,7 @@
|
||||
<tile x="42" y="15" texture="grass_top" rotation="0" solid="true"/>
|
||||
<tile x="42" y="16" texture="grass_top" rotation="0" solid="true"/>
|
||||
<tile x="42" y="17" texture="grass_top" rotation="0" />
|
||||
<tile x="42" y="18" texture="grass_top" rotation="0" />
|
||||
<tile x="42" y="18" texture="npc_interact" rotation="2" />
|
||||
<tile x="42" y="19" texture="dirt_top_5" rotation="1" />
|
||||
<tile x="42" y="20" texture="dirt" rotation="0" />
|
||||
<tile x="42" y="21" texture="dirt" rotation="0" />
|
||||
@@ -8027,7 +8027,7 @@
|
||||
<tile x="43" y="15" texture="grass_top" rotation="0" solid="true"/>
|
||||
<tile x="43" y="16" texture="grass_top" rotation="0" solid="true"/>
|
||||
<tile x="43" y="17" texture="grass_top" rotation="0" solid="true"/>
|
||||
<tile x="43" y="18" texture="grass_top" rotation="0" />
|
||||
<tile x="43" y="18" texture="grass_top" rotation="0" solid="true"/>
|
||||
<tile x="43" y="19" texture="dirt_top_1" rotation="1" />
|
||||
<tile x="43" y="20" texture="dirt" rotation="0" />
|
||||
<tile x="43" y="21" texture="dirt_inner_top_left" rotation="2" />
|
||||
@@ -8479,7 +8479,7 @@
|
||||
<tile x="49" y="53" texture="dirt_top_right_1" rotation="3" />
|
||||
<tile x="49" y="54" texture="grass_top" rotation="0" />
|
||||
<tile x="49" y="55" texture="grass_top" rotation="0" />
|
||||
<tile x="49" y="56" texture="grass_top" rotation="0"/>
|
||||
<tile x="49" y="56" texture="grass_top" rotation="0" solid="true"/>
|
||||
<tile x="49" y="57" texture="water_grass_right_1" rotation="2" solid="true"/>
|
||||
<tile x="49" y="58" texture="water_grass_right_1" rotation="0" solid="true"/>
|
||||
<tile x="49" y="59" texture="grass_top" rotation="0" solid="true"/>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "xml.h"
|
||||
#include "components/particule_component.h"
|
||||
#include "components/map_linker.h"
|
||||
#include "systems/particule_system.h"
|
||||
#include "component.h"
|
||||
#include <malloc.h>
|
||||
#include "utility.h"
|
||||
@@ -25,12 +26,13 @@ component;
|
||||
cmp->texture = va_arg(args, void *);
|
||||
cmp->particules = malloc(sizeof(struct particule_component) * \
|
||||
(cmp->nb_max_particules + 1));
|
||||
sprites = malloc(sizeof(gc_sprite) * (cmp->nb_max_particules));
|
||||
sprites = malloc(sizeof(gc_sprite) * (cmp->nb_max_particules + 1));
|
||||
if (!cmp->particules || !sprites)
|
||||
return;
|
||||
for (int i = 0; i < cmp->nb_max_particules; i++) {
|
||||
cmp->particules[i].sprite = &sprites[i];
|
||||
cmp->particules[i].lifetime = 0;
|
||||
create_particule(&cmp->particules[i], i * 20, NULL, \
|
||||
(gc_vector2){0, 0});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,16 +50,17 @@ component;
|
||||
}
|
||||
cmp->type = xml_getintprop(n, "type");
|
||||
cmp->nb_max_particules = xml_getintprop(n, "nb_particules_max");
|
||||
cmp->texture = ml->tile->texture;
|
||||
cmp->texture = NULL;
|
||||
cmp->lifetime = xml_getintprop(n, "lifetime");
|
||||
cmp->particules = malloc(sizeof(struct particule_component) * \
|
||||
(cmp->nb_max_particules + 1));
|
||||
sprites = malloc(sizeof(gc_sprite) * (cmp->nb_max_particules));
|
||||
sprites = malloc(sizeof(gc_sprite) * (cmp->nb_max_particules + 1));
|
||||
if (!cmp->particules || !sprites)
|
||||
return;
|
||||
for (int i = 0; i < cmp->nb_max_particules; i++) {
|
||||
cmp->particules[i].sprite = &sprites[i];
|
||||
cmp->particules[i].lifetime = 0;
|
||||
create_particule(&cmp->particules[i], i * 20, NULL, \
|
||||
(gc_vector2){0, 0});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,8 +101,7 @@ gc_scene *scene, gc_engine *engine)
|
||||
|
||||
if (!player_entity)
|
||||
return;
|
||||
struct health_component *h_cmp = GETCMP(player_entity, health_component);
|
||||
if (h_cmp->dead) {
|
||||
if (GETCMP(player_entity, health_component)->dead) {
|
||||
combat_end(engine, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,22 +22,27 @@ void *texture, gc_vector2 pos)
|
||||
particule->lifetime = lifetime;
|
||||
particule->sprite->texture = texture;
|
||||
particule->sprite->pos = pos;
|
||||
particule->sprite->rect = (gc_int_rect){10, 10,0,0};
|
||||
particule->sprite->scale = (gc_vector2){0.5, 0.5};
|
||||
particule->sprite->rect = (gc_int_rect){16, 16,0,0};
|
||||
particule->sprite->scale = (gc_vector2){1, 1};
|
||||
}
|
||||
|
||||
void particule_draw(gc_engine *engine, void *system, \
|
||||
gc_entity *entity, float dt)
|
||||
{
|
||||
struct particule_component *pm = GETCMP(entity, particule_component);
|
||||
struct transform_component *tc = GETCMP(entity, transform_component);
|
||||
gc_vector2 player_pos;
|
||||
|
||||
if (!pm || !entity)
|
||||
if (!pm || !entity || !tc)
|
||||
return;
|
||||
player_pos = tc->position;
|
||||
for (int i = 0; i < pm->nb_max_particules; i++) {
|
||||
if (!pm->particules[i].sprite)
|
||||
if (!pm->particules[i].sprite || !pm->particules[i].sprite->texture)
|
||||
continue;
|
||||
tc->position = pm->particules[i].sprite->pos;
|
||||
sfmlrenderer_draw_texture(engine, entity, pm->particules[i].sprite, dt);
|
||||
}
|
||||
tc->position = player_pos;
|
||||
}
|
||||
|
||||
void particule_update_entity(gc_engine *engine, void *system, gc_entity *entity, \
|
||||
@@ -49,12 +54,11 @@ float dtime)
|
||||
|
||||
if (!ml || !tc || !cmp)
|
||||
return;
|
||||
cmp->texture = ml->tile->texture;
|
||||
for (int i = 0; i < cmp->nb_max_particules; i++)
|
||||
cmp->particules[i].lifetime -= (cmp->particules[i].lifetime) ? 1 : 0;
|
||||
for (int i = 0; i < cmp->nb_max_particules; i++) {
|
||||
if (!cmp->particules[i].lifetime)
|
||||
create_particule(&cmp->particules[i], cmp->lifetime, cmp->texture, tc->position);
|
||||
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);
|
||||
}
|
||||
}
|
||||
particule_draw(engine, system, entity, dtime);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user