class SpriteItem {
	constructor(
		private img: HTMLImageElement,
		private x: number,
		private y: number,
		private w: number,
		private h: number,
		private c: number = 1,
	) {}

	draw(ctx: CanvasRenderingContext2D, x: number, y: number, frame: number) {
		const offsetX = this.x + (frame % this.c) * this.w;

		ctx.drawImage(
			this.img,
			offsetX,
			this.y,
			this.w,
			this.h,
			Math.round(x),
			Math.round(y),
			this.w,
			this.h,
		);
	}

	get params() {
		return {
			w: this.w,
			h: this.h,
		};
	}
}

export default SpriteItem;
