aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libjin/Game/je_entity.cpp11
-rw-r--r--src/libjin/Game/je_entity.h79
-rw-r--r--src/libjin/Graphics/animation/je_clip.h2
-rw-r--r--src/libjin/Graphics/je_graphic.h1
-rw-r--r--src/libjin/Graphics/je_sprite_batch.cpp0
-rw-r--r--src/libjin/Graphics/je_sprite_batch.h20
-rw-r--r--src/libjin/Graphics/particle/je_particle.h71
-rw-r--r--src/libjin/Graphics/particle/je_particle_emitter.h64
-rw-r--r--src/libjin/Graphics/particle/je_particle_system.h7
9 files changed, 143 insertions, 112 deletions
diff --git a/src/libjin/Game/je_entity.cpp b/src/libjin/Game/je_entity.cpp
index 1396518..e69de29 100644
--- a/src/libjin/Game/je_entity.cpp
+++ b/src/libjin/Game/je_entity.cpp
@@ -1,11 +0,0 @@
-#include "je_entity.h"
-
-namespace JinEngine
-{
- namespace Game
- {
-
-
-
- } // namespace Game
-} // namespace JinEngine \ No newline at end of file
diff --git a/src/libjin/Game/je_entity.h b/src/libjin/Game/je_entity.h
index 781bdc3..cf4eeb0 100644
--- a/src/libjin/Game/je_entity.h
+++ b/src/libjin/Game/je_entity.h
@@ -1,16 +1,7 @@
-#ifndef __JE_GAME_OBJECT_H
-#define __JE_GAME_OBJECT_H
+#ifndef __JE_ENTITY_H
+#define __JE_ENTITY_H
-#include "../core/je_configuration.h"
-#if defined(jin_game)
-
-#include <list>
-#include <map>
-#include <set>
-
-#include "../common/je_object.h"
-#include "../common/je_types.h"
-#include "../graphics/je_sprite.h"
+#include "je_game_object.h"
namespace JinEngine
{
@@ -18,69 +9,17 @@ namespace JinEngine
{
///
- /// Game object base class.
+ ///
///
- class Entity : public Object
+ class Entity : public GameObject
{
public:
- ///
- ///
- ///
- virtual ~Entity();
-
- ///
- ///
- ///
- void lifecycle();
-
- ///
- ///
- ///
- void setVisible(bool isVisible);
-
- ///
- ///
- ///
- void setActive(bool isActive);
-
- ///
- ///
- ///
- void setOrder(uint32 order);
-
- protected:
- virtual void onAlive();
- virtual void onUpdate(float dt);
- virtual void onDraw();
- virtual void onDestroy();
-
- uint32 mLayer; // layer where entity belongs
- uint32 mOrder; // render index in layer
- uint32 mTag; // tag of entity, support 32 tags now
- bool mIsVisible; // if the entity is visible or not
- bool mIsActive; // if the entity is joined into the logic
-
- ///
- /// Position of entity.
- ///
- Math::Vector2<float> mPosition;
+ private:
};
- ///
- /// Entity list. For quickly adding and removing entities.
- ///
- typedef std::list<Entity*> EntityList;
-
- ///
- /// Entity set. For searching and keeps entities unique and sorted.
- ///
- typedef std::set<Entity*> EntitySet;
-
- } // namespace Game
-} // namespace JinEngine
-
-#endif // jin_game
+ }
+}
-#endif \ No newline at end of file
+#endif \ No newline at end of file
diff --git a/src/libjin/Graphics/animation/je_clip.h b/src/libjin/Graphics/animation/je_clip.h
index eedffc0..6b6b0df 100644
--- a/src/libjin/Graphics/animation/je_clip.h
+++ b/src/libjin/Graphics/animation/je_clip.h
@@ -17,6 +17,8 @@ namespace JinEngine
class Clip
{
public:
+ void onUpdate(float dt);
+
void start();
void pause();
void stop();
diff --git a/src/libjin/Graphics/je_graphic.h b/src/libjin/Graphics/je_graphic.h
index d18575e..3410d61 100644
--- a/src/libjin/Graphics/je_graphic.h
+++ b/src/libjin/Graphics/je_graphic.h
@@ -18,6 +18,7 @@ namespace JinEngine
// Graphic
// |-Texture
// |-Canvas
+ // |-TextureFont
//
///
diff --git a/src/libjin/Graphics/je_sprite_batch.cpp b/src/libjin/Graphics/je_sprite_batch.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Graphics/je_sprite_batch.cpp
+++ /dev/null
diff --git a/src/libjin/Graphics/je_sprite_batch.h b/src/libjin/Graphics/je_sprite_batch.h
deleted file mode 100644
index 359ce24..0000000
--- a/src/libjin/Graphics/je_sprite_batch.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __JE_SPRITE_BATCH_H
-#define __JE_SPRITE_BATCH_H
-
-namespace JinEngine
-{
- namespace Graphics
- {
-
- ///
- /// For reducing draw call.
- ///
- class SpriteBatch
- {
-
- };
-
- } // namespace Graphics
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Graphics/particle/je_particle.h b/src/libjin/Graphics/particle/je_particle.h
index 474e15b..cb176bb 100644
--- a/src/libjin/Graphics/particle/je_particle.h
+++ b/src/libjin/Graphics/particle/je_particle.h
@@ -10,6 +10,77 @@ namespace JinEngine
class ParticleSystem;
+ struct LifeTimeDef
+ {
+ bool enableRandom = false;
+ union
+ {
+ struct
+ {
+ float min, max;
+ } random;
+ float life;
+ } life;
+ };
+
+ struct SpeedOverTimeDef
+ {
+ bool enable = false;
+ bool enableRandom = false;
+ union
+ {
+ struct
+ {
+ Math::Vector2<float> startFloor;
+ Math::Vector2<float> startCeil;
+ Math::Vector2<float> endFloor;
+ Math::Vector2<float> endCeil;
+ } random;
+ struct
+ {
+ Math::Vector2<float> start;
+ Math::Vector2<float> end;
+ } speed;
+ } speed;
+ };
+
+ struct SizeOverTimeDef
+ {
+ bool enable = false;
+ bool enableRandom = false;
+ union {
+ struct {
+ float startFloor = 1;
+ float startCeil = 1;
+ float endFloor = 1;
+ float endCeil = 1;
+ } random;
+ struct {
+ float start = 1;
+ float end = 1;
+ } size;
+ } size;
+ };
+
+ struct ColorOverTime
+ {
+ bool enable = false;
+ Color colorStart = Color::WHITE;
+ Color colorEnd = Color::WHITE;
+ };
+
+ ///
+ ///
+ ///
+ struct ParticleDef
+ {
+ LifeTimeDef lifeTimeDef; ///<
+ // Optional definitions.
+ SpeedOverTimeDef speedOverTimeDef; ///<
+ SizeOverTimeDef sizeOverTimeDef; ///<
+ ColorOverTime colorOverTimeDef; ///<
+ };
+
///
/// A single particle contains various properties of particle, such as position, accelaration, color and
/// other attributes changed over time.
diff --git a/src/libjin/Graphics/particle/je_particle_emitter.h b/src/libjin/Graphics/particle/je_particle_emitter.h
index 95b7875..e700f16 100644
--- a/src/libjin/Graphics/particle/je_particle_emitter.h
+++ b/src/libjin/Graphics/particle/je_particle_emitter.h
@@ -11,29 +11,75 @@ namespace JinEngine
namespace Graphics
{
+ struct PositionDef
+ {
+ bool enableRandom = false;
+ union
+ {
+ struct
+ {
+ Math::Vector2<float> min;
+ Math::Vector2<float> max;
+ } random;
+ Math::Vector2<float> position;
+ } position;
+ };
+
+ struct DirectionDef
+ {
+ bool enableRandom = false;
+ union
+ {
+ struct
+ {
+ float min = 0;
+ float max = 0;
+ } random;
+ float direction = 0;
+ } direction;
+ };
+
+ struct EmitRateDef
+ {
+ bool enableRandom = false;
+ union
+ {
+ struct
+ {
+ float min = 1;
+ float max = 1;
+ } random;
+ float rate = 1;
+ } rate;
+ };
+
///
/// Definition of particle emitter.
///
struct ParticleEmitterDef : public Temporary
{
- Math::Vector2<float> position;
-
+ PositionDef positionDef; ///< Emit position(relativily to the particle system center).
+ DirectionDef directionDef; ///< Emit direction.
+ EmitRateDef emitRateDef; ///< Emit rate.
+ ///
+ /// Particle definition.
+ ///
+ ParticleDef particleDef; ///< Particle definition.
};
+ ///
+ /// Emit a single particle.
+ ///
class ParticleEmitter
{
public:
ParticleEmitter(const ParticleEmitterDef& def);
///
- /// Create new particle.
- ///
- Particle* emit();
-
- ///
- /// Emitter position.
+ /// Emit a particle, particle system should assign particle value to the particle in particle pool,
+ /// but not use this return particle.
///
- Math::Vector2<float> mPosition;
+ Particle emit();
///
///
diff --git a/src/libjin/Graphics/particle/je_particle_system.h b/src/libjin/Graphics/particle/je_particle_system.h
index c5db938..9ccb8df 100644
--- a/src/libjin/Graphics/particle/je_particle_system.h
+++ b/src/libjin/Graphics/particle/je_particle_system.h
@@ -4,6 +4,7 @@
#include <vector>
#include "../../common/je_temporary.h"
+#include "../../game/je_game_object.h"
#include "../je_sprite.h"
@@ -21,14 +22,16 @@ namespace JinEngine
///
struct ParticleSystemDef : public Temporary
{
- uint maxParticleCount = 1; ///< Max count of particles. 1 by default.
+ uint maxParticleCount = 1; ///< Max count of particles in pool. 1 by default.
+
+ ParticleEmitter emitterDef;
};
///
/// Particle emitter, handle all particles it emitts.
///
- class ParticleSystem
+ class ParticleSystem : public Game::GameObject
{
public:
///