import { AnimationPhases, AnimationName, AnimationState } from "../type";

export function getAnimationStates(
  spriteW: number,
  spriteH: number,
  animationPhases: AnimationPhases[]
) {
  let animationStates: unknown = {};

  animationPhases.forEach((state, index) => {
    let loc = [];
    for (let j = 0; j < state.frames; j++) {
      let x = j * spriteW;
      let y = index * spriteH;
      loc.push({ x, y });
    }

    (animationStates as Record<AnimationName, AnimationState>)[state.name] = {
      loc,
    };
  });

  return animationStates as Record<AnimationName, AnimationState>;
}
