mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-18 17:59:21 +01:00
Add player turning (Finally)
This commit is contained in:
@@ -2,17 +2,21 @@
|
||||
#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) {
|
||||
Animation::Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect, bool isLooping): m_pTexture(pTexture), m_SrcRect(srcRect), m_Frames(frames), m_isLooping(isLooping), m_FrameDuration(frameDuration) {
|
||||
|
||||
}
|
||||
void Animation::Update(float elapsedSec) {
|
||||
if (m_isPlaying) {
|
||||
m_FrameTimer -= elapsedSec;
|
||||
if (m_FrameTimer <= 0.0f) {
|
||||
m_FrameTimer = 0.1f;
|
||||
m_FrameTimer = m_FrameDuration;
|
||||
++m_CurrentFrame;
|
||||
if (m_CurrentFrame >= m_Frames) {
|
||||
m_CurrentFrame = 0;
|
||||
if(!m_isLooping) {
|
||||
m_hasPlayedOnce = true;
|
||||
m_isPlaying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user