import RenderComponent from './RenderComponent.js'; /** * Component that holds data for rendering an animated sprite. */ export default class SpriteComponent extends RenderComponent { #private; /** The source image for the sprite. */ img: HTMLImageElement; /** Number of rows in the spritesheet. */ rows: number; /** Number of columns in the spritesheet. */ cols: number; /** The starting column for the current animation loop. */ startCol: number; /** The ending column for the current animation loop. */ endCol: number; /** The pixel width of a single animation frame. */ frameWidth: number; /** The pixel height of a single animation frame. */ frameHeight: number; /** The current frame index being displayed. */ currentFrame: number; /** Whether the sprite is horizontally flipped. */ flip: boolean; /** Duration of each animation frame in milliseconds. */ frameDuration: number; /** Whether the sprite is currently playing its animation. */ playing: boolean; constructor(img: HTMLImageElement, rows: number, cols: number, startCol: number, endCol: number); /** * Draws the current frame of the sprite. * @param ctx The canvas 2D rendering context. */ draw(ctx: CanvasRenderingContext2D): void; }