aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-11 21:27:54 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-11 21:27:54 +0100
commitcf96d9639dbd18df6451a07fd7b623616e842c4a (patch)
treeec9567200c2e35a30953f113bc5d6cce9a1e8884
parent3d97f7c60536bf14f314cc703883f74345aacd21 (diff)
adjusted rendering and example
-rw-r--r--src/crepe/system/RenderSystem.cpp1
-rw-r--r--src/example/rendering_particle.cpp10
2 files changed, 6 insertions, 5 deletions
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 3de8330..3fbd175 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -49,6 +49,7 @@ void RenderSystem::render_particle(const ParticleEmitter& em, Transform & tm){
SDLContext & render = SDLContext::get_instance();
for (const Particle& p : em.data.particles) {
+ if (!p.active) continue;
tm.position = p.position;
render.draw(em.data.sprite, tm , *curr_cam);
}
diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp
index 54a9c23..bd4ceb4 100644
--- a/src/example/rendering_particle.cpp
+++ b/src/example/rendering_particle.cpp
@@ -21,17 +21,17 @@ using namespace crepe;
using namespace std;
int main(int argc, char * argv[]) {
- GameObject game_object(0, "", "", Vector2{0, 0}, 0, 0.1);
+ GameObject game_object(0, "", "", Vector2{100, 0}, 0, 0.1);
Color color(0, 0, 0, 0);
Sprite test_sprite = game_object.add_component<Sprite>(
make_shared<Texture>("../asset/texture/img.png"), color,
FlipSettings{false, false});
game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{
.position = {0, 0},
- .max_particles = 100,
- .emission_rate = 0.5,
- .min_speed = 1,
- .max_speed = 1,
+ .max_particles = 10,
+ .emission_rate = 0.1,
+ .min_speed = 10,
+ .max_speed = 10,
.min_angle = 0,
.max_angle = 0,
.begin_lifespan = 0,