Good afternoon!
I'm creating a small 2d game in directx11, I'm trying to animate the sprites.
See my doubt:
I have a sprite sheet with 18 frames, 3 rows with 6 columns.
I can do the animation very manually. Problem is that if I need to increase the columns or rows I need to change all the animation code.
I would like if someone there can help me to make this code more automatic.
this is the code:
float *v = new float[m_NumRow];
for (size_t i = 0; i < m_NumRow; i++)
{
v[i] = i*(1.0f/m_NumRow);
}
float t = 0, k = 1.0f/m_NumRow;
if (currentFrame >= m_NumCol)
{
t = v[1];
}
if (currentFrame >= (m_NumCol + m_NumCol))
{
t = v[2];
}
if (currentFrame < m_NumCol)
t = v[0];
m_vertices[0].uv.x = (float)(currentFrame) / m_NumCol;
m_vertices[0].uv.y = t + k;