mirror of
https://github.com/echojc/osu-ds.git
synced 2025-06-18 17:05:36 -04:00
30 lines
718 B
C++
30 lines
718 B
C++
#include "pAnimation.h"
|
|
|
|
pAnimation::pAnimation(TextureType texture, u32 framecount, u32 fps, s32 x, s32 y, u32 width, u32 height, DrawOrigin origin, FieldType type, rgb color, u32 alpha)
|
|
: pSprite(texture, x, y, width, height, origin, type, color, alpha)
|
|
{
|
|
mFrameCount = framecount;
|
|
mFrameCurrent = 0;
|
|
mOrigTexture = texture;
|
|
|
|
mUpdatesPerFrame = 60.0 / fps;
|
|
mUpdatesWaited = 0;
|
|
}
|
|
|
|
void pAnimation::Update()
|
|
{
|
|
while (mUpdatesWaited >= mUpdatesPerFrame)
|
|
{
|
|
mUpdatesWaited -= mUpdatesPerFrame;
|
|
|
|
++mFrameCurrent;
|
|
if (mFrameCurrent >= mFrameCount)
|
|
mFrameCurrent = 0;
|
|
|
|
Texture = (TextureType)(mOrigTexture + mFrameCurrent);
|
|
}
|
|
|
|
++mUpdatesWaited;
|
|
|
|
pSprite::Update();
|
|
} |