aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libjin/Common/je_exception.h4
-rw-r--r--src/libjin/Filesystem/je_asset_database.h2
-rw-r--r--src/libjin/Game/je_entity.h14
-rw-r--r--src/libjin/Game/je_scene.h8
-rw-r--r--src/libjin/Graphics/je_sprite.cpp8
-rw-r--r--src/libjin/Graphics/je_sprite.h12
6 files changed, 33 insertions, 15 deletions
diff --git a/src/libjin/Common/je_exception.h b/src/libjin/Common/je_exception.h
index 7c66af8..19fdedb 100644
--- a/src/libjin/Common/je_exception.h
+++ b/src/libjin/Common/je_exception.h
@@ -9,10 +9,10 @@ namespace JinEngine
///
/// Built-in exception class.
///
- class JinException : public std::exception
+ class Exception : public std::exception
{
public:
- JinException();
+ Exception();
const char* what() const throw();
};
diff --git a/src/libjin/Filesystem/je_asset_database.h b/src/libjin/Filesystem/je_asset_database.h
index 8c30fc1..1d50a2f 100644
--- a/src/libjin/Filesystem/je_asset_database.h
+++ b/src/libjin/Filesystem/je_asset_database.h
@@ -88,7 +88,7 @@ namespace JinEngine
/// @param recursive Recursivily search folder.
/// @return File list under given directory.
///
- std::vector<std::string> getFiles(const char* path, bool recursive);
+ std::vector<std::string> getFiles(const char* directory, bool recursive = false);
///
/// Get full path of asset.
diff --git a/src/libjin/Game/je_entity.h b/src/libjin/Game/je_entity.h
index 4a252da..d67a71f 100644
--- a/src/libjin/Game/je_entity.h
+++ b/src/libjin/Game/je_entity.h
@@ -10,6 +10,7 @@
#include "../common/je_object.h"
#include "../common/je_types.h"
+#include "../graphics/je_sprite.h"
namespace JinEngine
{
@@ -43,15 +44,20 @@ namespace JinEngine
///
void setActive(bool isActive);
+ ///
+ ///
+ ///
+ void setOrder(uint32 order);
+
protected:
virtual void onAlive();
virtual void onUpdate(float dt);
virtual void onDraw();
- virtual void onDie();
+ virtual void onDestroy();
- uint32 layer; // layer where entity belongs
- uint32 index; // render index in layer
- uint64 tag; // tag of entity, 64 now
+ 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
diff --git a/src/libjin/Game/je_scene.h b/src/libjin/Game/je_scene.h
index f510a1f..6100166 100644
--- a/src/libjin/Game/je_scene.h
+++ b/src/libjin/Game/je_scene.h
@@ -28,7 +28,7 @@ namespace JinEngine
///
///
///
- EntityList& getEntitiesByTag(uint64 tag);
+ EntityList& getEntitiesByTag(uint32 tag);
///
///
@@ -38,7 +38,7 @@ namespace JinEngine
///
///
///
- void setEntitiesActiveByTag(uint64 tag);
+ void setEntitiesActiveByTag(uint32 tag);
///
///
@@ -53,7 +53,7 @@ namespace JinEngine
///
///
///
- void removeEntitiesByTag(uint64 tag);
+ void removeEntitiesByTag(uint32 tag);
protected:
// all entities
@@ -61,7 +61,7 @@ namespace JinEngine
// all entities grouped by layer, render order
std::map<uint32, EntityList> layers;
// all entities grouped by tag
- std::map<uint64, EntityList> tags;
+ std::map<uint32, EntityList> tags;
};
diff --git a/src/libjin/Graphics/je_sprite.cpp b/src/libjin/Graphics/je_sprite.cpp
index 3ac976a..4d4fa12 100644
--- a/src/libjin/Graphics/je_sprite.cpp
+++ b/src/libjin/Graphics/je_sprite.cpp
@@ -5,7 +5,13 @@ namespace JinEngine
namespace Graphics
{
-
+ void Sprite::onRender()
+ {
+ if (mShader != nullptr)
+ mShader->use();
+
+ mShader->unuse();
+ }
} // namespace Graphics
} // namespace JinEngine \ No newline at end of file
diff --git a/src/libjin/Graphics/je_sprite.h b/src/libjin/Graphics/je_sprite.h
index 1d3c950..74f5d27 100644
--- a/src/libjin/Graphics/je_sprite.h
+++ b/src/libjin/Graphics/je_sprite.h
@@ -13,7 +13,7 @@ namespace JinEngine
{
///
- /// A sprite is unit of rendering
+ /// A sprite is unit of rendering.
///
class Sprite
{
@@ -23,14 +23,20 @@ namespace JinEngine
void setScale(float x, float y);
void setColor(Color color);
void setShader(const Shader* shader);
+ void setGraphic(const Graphic* graphic);
+
+ ///
+ /// Render callback.
+ ///
+ void onRender();
private:
Math::Vector2<int> mPosition;
Math::Vector2<float> mOrigin;
Math::Vector2<float> mScale;
Color mColor;
- const Shader* mShader;
- const Graphic* mGraphic;
+ Shader* mShader;
+ Graphic* mGraphic;
};