import { Character } from './character';
import SpriteItem from '../sprite-item';

export class SpriteCharacter implements Character {
	private currentOffset: number = 0;

	constructor(private sprite: SpriteItem) {}

	update(dt: number) {
		this.currentOffset = (this.currentOffset + dt / 200) % 100;
	}

	draw(ctx: CanvasRenderingContext2D) {
		const { w, h } = this.sprite.params;
		this.sprite.draw(ctx, -w / 2, (-h * 7) / 8, Math.round(this.currentOffset));

		// ctx.fillStyle = 'yellow';
		// ctx.beginPath();
		// ctx.arc(0, 0, 1, 0, 2 * Math.PI, false);
		// ctx.fill();
	}
}

export default SpriteCharacter;
