Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
YukinoHayakawa committed Jan 7, 2021
1 parent 42b0b3d commit 7cd2a2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
14 changes: 7 additions & 7 deletions DemoEcsFireworks/System_fireworks_explode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ struct System_fireworks_explode
{
auto &f_c = USAGI_COMPONENT(e, ComponentColor);

spark.val<ComponentSpark>().fade_time_total =
spark.val<ComponentSpark>().fade_time_left =
spark.component<ComponentSpark>().fade_time_total =
spark.component<ComponentSpark>().fade_time_left =
dis_ft(gen);
spark.val<ComponentSpark>().base_color = f_c.rgb;
spark.component<ComponentSpark>().base_color = f_c.rgb;

// copy the rocket position & color
spark.val<ComponentPosition>() =
spark.component<ComponentPosition>() =
USAGI_COMPONENT(e, ComponentPosition);
spark.val<ComponentColor>() =
spark.component<ComponentColor>() =
USAGI_COMPONENT(e, ComponentColor);

// set particle props
spark.val<ComponentPhysics>().velocity =
spark.component<ComponentPhysics>().velocity =
polarToCartesian(dis_v(gen), dis(gen));
spark.val<ComponentSprite>().size = 5;
spark.component<ComponentSprite>().size = 5;

db.insert(spark);
// db.create may invalidate the entity view
Expand Down
20 changes: 9 additions & 11 deletions DemoEcsFireworks/System_fireworks_spawn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ struct System_fireworks_spawn

while(time_pool > 0.f)
{
fireworks.val<ComponentFireworks>().num_sparks = 200;
fireworks.val<ComponentFireworks>().time_to_explode = 2;
fireworks.val<ComponentPosition>().position = { dis_x(gen), 0 };
fireworks.val<ComponentPhysics>().velocity = { 0, dis_v(gen) };
fireworks.val<ComponentPhysics>().acceleration = { 0, 0 };
fireworks.val<ComponentSprite>().size = 10;
fireworks.val<ComponentColor>().rgb =
{ dis_color(gen), dis_color(gen), dis_color(gen) };

const EntityId e = db.insert(fireworks);
(void)e;
fireworks(ComponentFireworks()).num_sparks = 200;
fireworks(ComponentFireworks()).time_to_explode = 2;
fireworks(ComponentPosition()).position = { dis_x(gen), 0 };
fireworks(ComponentPhysics()).velocity = { 0, dis_v(gen) };
fireworks(ComponentPhysics()).acceleration = { 0, 0 };
fireworks(ComponentSprite()).size = 10;
fireworks(ComponentColor()).rgb =
{ dis_color(gen), dis_color(gen), dis_color(gen) };
db.insert(fireworks);
time_pool -= 0.03f;
}
}
Expand Down

0 comments on commit 7cd2a2a

Please sign in to comment.