Skip to content

Commit

Permalink
Looping
Browse files Browse the repository at this point in the history
  • Loading branch information
gecko0307 committed Aug 15, 2024
1 parent ca3a85a commit e77322f
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions extensions/iqm/src/dagon/ext/iqm.d
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class Actor: Owner, Drawable
float defaultFramerate = 24.0f;
float speed = 1.0f;
float blendSpeed = 8.0f;
bool looping = true;

GLuint vao = 0;
GLuint vbo = 0;
Expand Down Expand Up @@ -279,20 +280,25 @@ class Actor: Owner, Drawable

if (state.t >= 1.0f)
{
state.t = 0.0f;
if (state.nextFrame != state.currentFrame)
state.t = 1.0f;

if (looping)
{
state.currentFrame++;
state.nextFrame++;

if (state.currentFrame == animation.firstFrame + animation.numFrames - 1)
{
state.nextFrame = animation.firstFrame;
}
else if (state.currentFrame == animation.firstFrame + animation.numFrames)
state.t = 0.0f;
if (state.nextFrame != state.currentFrame)
{
state.currentFrame = animation.firstFrame;
state.nextFrame = state.currentFrame + 1;
state.currentFrame++;
state.nextFrame++;

if (state.currentFrame == animation.firstFrame + animation.numFrames - 1)
{
state.nextFrame = animation.firstFrame;
}
else if (state.currentFrame == animation.firstFrame + animation.numFrames)
{
state.currentFrame = animation.firstFrame;
state.nextFrame = state.currentFrame + 1;
}
}
}
}
Expand Down

0 comments on commit e77322f

Please sign in to comment.