demo update
This commit is contained in:
@@ -27,42 +27,11 @@ class Sprite {
|
||||
Vec2 position, size;
|
||||
float scale;
|
||||
Color color;
|
||||
|
||||
// ----
|
||||
// Getters
|
||||
// ----
|
||||
|
||||
/** Get sprite drawing mode. */
|
||||
inline const SpriteMode& getMode() const { return mode; };
|
||||
|
||||
// ----
|
||||
// Setters
|
||||
// ----
|
||||
|
||||
/** Set sprite drawing mode. */
|
||||
void setMode(const SpriteMode& t_val) { mode = t_val; }
|
||||
|
||||
// ----
|
||||
// Other
|
||||
// ----
|
||||
|
||||
/** Flip texture horizontally. */
|
||||
inline void flipHorizontally(const u8& t_set) { _flipH = t_set; };
|
||||
|
||||
/** Flip texture vertically. */
|
||||
inline void flipVertically(const u8& t_set) { _flipV = t_set; };
|
||||
|
||||
/** Check if texture is vertically flipped. */
|
||||
inline const u8& isFlippedVertically() const { return _flipV; };
|
||||
|
||||
/** Check if texture is horizontally flipped. */
|
||||
inline const u8& isFlippedHorizontally() const { return _flipH; };
|
||||
SpriteMode mode;
|
||||
bool flipHorizontal, flipVertical;
|
||||
|
||||
private:
|
||||
SpriteMode mode;
|
||||
u8 _isSizeSet, _flipH, _flipV;
|
||||
void setDefaultColor();
|
||||
void setDefaultLODAndClut();
|
||||
};
|
||||
|
||||
} // namespace Tyra
|
||||
|
||||
@@ -68,7 +68,7 @@ void RendererCore2D::render(Sprite* sprite,
|
||||
auto* rect = rects[context];
|
||||
float sizeX, sizeY;
|
||||
|
||||
if (sprite->getMode() == MODE_REPEAT) {
|
||||
if (sprite->mode == MODE_REPEAT) {
|
||||
sizeX = sprite->size.x;
|
||||
sizeY = sprite->size.y;
|
||||
} else {
|
||||
@@ -84,10 +84,10 @@ void RendererCore2D::render(Sprite* sprite,
|
||||
else if (sizeY > sizeX)
|
||||
texS = texMax / (sizeY / sizeX);
|
||||
|
||||
rect->t0.s = sprite->isFlippedHorizontally() ? texS : 0.0F;
|
||||
rect->t0.t = sprite->isFlippedVertically() ? texT : 0.0F;
|
||||
rect->t1.s = sprite->isFlippedHorizontally() ? 0.0F : texS;
|
||||
rect->t1.t = sprite->isFlippedVertically() ? 0.0F : texT;
|
||||
rect->t0.s = sprite->flipHorizontal ? texS : 0.0F;
|
||||
rect->t0.t = sprite->flipVertical ? texT : 0.0F;
|
||||
rect->t1.s = sprite->flipHorizontal ? 0.0F : texS;
|
||||
rect->t1.t = sprite->flipVertical ? 0.0F : texT;
|
||||
|
||||
rect->color.r = sprite->color.r;
|
||||
rect->color.g = sprite->color.g;
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace Tyra {
|
||||
|
||||
Sprite::Sprite() {
|
||||
id = rand() % 1000000;
|
||||
_flipH = false;
|
||||
_flipV = false;
|
||||
flipHorizontal = false;
|
||||
flipVertical = false;
|
||||
size.set(32.0F, 32.0F);
|
||||
position.set(100.0F, 100.0F);
|
||||
scale = 1.0F;
|
||||
|
||||
Reference in New Issue
Block a user