Pre Point2f Nuke

Fixed drawing,
Added general optimisations
This commit is contained in:
Bram Verhulst
2024-04-16 14:08:41 +02:00
parent f50597d1a5
commit 64e96ab209
13 changed files with 228 additions and 177 deletions

View File

@@ -1,5 +1,7 @@
#include "pch.h"
#include "Animation.h"
#include "utils.h"
Animation::Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect): m_pTexture(pTexture), m_SrcRect(srcRect), m_Frames(frames) {
}
@@ -17,10 +19,13 @@ void Animation::Update(float elapsedSec) {
}
}
}
void Animation::Draw(const Point2f& pos, float angle) const {
void Animation::Draw(const Point2f& pos) const {
Draw(pos, Rectf{ pos.x, pos.y, m_SrcRect.width, m_SrcRect.height });
}
void Animation::Draw(const Point2f& pos, const Rectf& dst) const {
Rectf src = m_SrcRect;
src.left += m_CurrentFrame * src.width;
auto dst = Rectf { pos.x, pos.y, src.width, src.height };
m_pTexture->Draw(dst, src, m_isFlipped);
}

View File

@@ -8,7 +8,8 @@ public:
~Animation();
void Update(float elapsedSec);
void Draw(const Point2f& pos, float angle = 0.0f) const;
void Draw(const Point2f& pos) const;
void Draw(const Point2f& pos, const Rectf& dst) const;
void SetPlaying(bool isPlaying) {
m_isPlaying = isPlaying;