aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/je_sprite.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Graphics/je_sprite.h')
-rw-r--r--src/libjin/Graphics/je_sprite.h73
1 files changed, 62 insertions, 11 deletions
diff --git a/src/libjin/Graphics/je_sprite.h b/src/libjin/Graphics/je_sprite.h
index 3b96162..65e00eb 100644
--- a/src/libjin/Graphics/je_sprite.h
+++ b/src/libjin/Graphics/je_sprite.h
@@ -1,34 +1,85 @@
-#ifndef __JE_SPRITE_H
-#define __JE_SPRITE_H
+#ifndef __JE_SPRITE_H__
+#define __JE_SPRITE_H__
#include "../common/je_types.h"
#include "../math/je_vector2.hpp"
-#include "shader/je_shader.h"
+#include "shaders/je_shader.h"
#include "je_color.h"
namespace JinEngine
{
namespace Graphics
{
+
///
- /// A sprite is unit of rendering, logic and events.
+ /// A sprite is unit of rendering. Animation is based on sprite, but not texture or other graphic stuff.
///
class Sprite
{
public:
- void setOrigin(float x, float y);
- void setPosition(int x, int y);
- void setScale(float x, float y);
+ Sprite();
+ virtual ~Sprite();
+
+ enum Origin
+ {
+ TopLeft,
+ TopCenter,
+ TopRight,
+ MiddleLeft,
+ MiddleCenter,
+ MiddleRight,
+ BottomLeft,
+ BottomCenter,
+ BottomRight
+ };
+
+ void setQuad(int x, int y, int w, int h);
+ void setRotation(float r);
+ void setOrigin(Origin origin);
+ void setOrigin(int x, int y);
+ void setPosition(float x, float y);
+ void setScale(float sx, float sy);
void setColor(Color color);
- void setShader(const Shader* shader);
+ void setShader(Shaders::Shader* shader);
+ void setGraphic(const Graphic* graphic);
+
+ void move(float x, float y);
+ void rotate(float r);
+ void scale(float sx, float sy);
+
+ float getRotation() { return mRotation; }
+ Math::Vector2<int> getSize() { return Math::Vector2<int>(mQuad.w, mQuad.h); }
+ const Math::Quad& getQuad() { return mQuad; }
+ const Math::Vector2<float>& getPosition() { return mPosition; }
+ const Math::Vector2<int>& getOrigin() { return mOrigin; }
+ const Math::Vector2<float>& getScale() { return mScale; }
+ const Color& getColor() { return mColor; }
+ const Graphic* getGraphic() { return mGraphic; }
+ const Shaders::Shader* getShader() { return mShader; }
+
+ ///
+ /// Render callback.
+ ///
+ virtual void render();
private:
- Math::Vector2<int> mPosition;
- Math::Vector2<float> mOrigin;
+ ///
+ /// Origin must be 0~1 float value.
+ ///
+ Math::Vector2<float> mPosition;
+ Math::Vector2<int> mOrigin;
Math::Vector2<float> mScale;
+ float mRotation;
Color mColor;
- const Shader* mShader;
+
+ Math::Quad mQuad;
+
+ bool mIsOriginEnum;
+ Origin mOriginEnum;
+
+ Shaders::Shader* mShader;
+ const Graphic* mGraphic;
};