mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-17 03:41:48 +01:00
Pre Point2f Nuke
Fixed drawing, Added general optimisations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user