aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-17 14:06:02 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-17 14:06:02 +0100
commitc00c83ee9982a7decda341ace95303f131d1b5c0 (patch)
tree097a81e7d5a7857e22e737a27de5481fd0e6c260 /src/example
parentcc2ec343367ebaa3b6a6142532f7a067c3c981a1 (diff)
parent20d19e3c714d3e8ca3e35c170c07c563ecc719bb (diff)
Merge branch 'jaro/particle-system-improvement' of github.com:lonkaars/crepe
Diffstat (limited to 'src/example')
-rw-r--r--src/example/game.cpp20
-rw-r--r--src/example/rendering_particle.cpp22
2 files changed, 20 insertions, 22 deletions
diff --git a/src/example/game.cpp b/src/example/game.cpp
index 61f8760..22effd2 100644
--- a/src/example/game.cpp
+++ b/src/example/game.cpp
@@ -1,4 +1,5 @@
#include "api/CircleCollider.h"
+#include "api/ParticleEmitter.h"
#include "api/Scene.h"
#include "manager/ComponentManager.h"
#include "manager/Mediator.h"
@@ -258,6 +259,25 @@ public:
})
.active
= false;
+ Asset img5{"asset/texture/square.png"};
+
+ GameObject particle = new_object(
+ "Name", "Tag", vec2{screen_size_width / 2, screen_size_height / 2}, 0, 1);
+ auto & particle_image = particle.add_component<Sprite>(img5, Sprite::Data{
+ .size = {5, 5},
+ });
+ auto & test
+ = particle.add_component<ParticleEmitter>(particle_image, ParticleEmitter::Data{
+ .offset = {0, 0},
+ .max_particles = 256,
+ .emission_rate = 1,
+ .min_speed = 10,
+ .max_speed = 20,
+ .min_angle = -20,
+ .max_angle = 20,
+ .begin_lifespan = 0,
+ .end_lifespan = 5,
+ });
}
string get_name() const { return "scene1"; }
diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp
index 13e625f..add43f4 100644
--- a/src/example/rendering_particle.cpp
+++ b/src/example/rendering_particle.cpp
@@ -18,28 +18,6 @@
using namespace crepe;
using namespace std;
-/*
- auto & test = game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{
- .position = {0, 0},
- .max_particles = 10,
- .emission_rate = 0.1,
- .min_speed = 6,
- .max_speed = 20,
- .min_angle = -20,
- .max_angle = 20,
- .begin_lifespan = 0,
- .end_lifespan = 60,
- .force_over_time = vec2{0, 0},
- .boundary{
- .width = 1000,
- .height = 1000,
- .offset = vec2{0, 0},
- .reset_on_exit = false,
- },
- .sprite = test_sprite,
- });
- */
-
class TestScene : public Scene {
public:
void load_scene() {