This commit is contained in:
kolaflash
2025-12-25 20:01:32 +01:00
parent e5bc240056
commit c6b1755d32
15 changed files with 140 additions and 70 deletions
+10
View File
@@ -1,3 +1,5 @@
import { loadImage } from "./loadImage.ts";
export type Sprite = {
image: HTMLImageElement;
xFrames: number;
@@ -20,6 +22,14 @@ export function createSprite(
};
}
export async function fromSrc(
src: string,
xFrames: number,
yFrames: number,
): Promise<Sprite> {
return createSprite(await loadImage(src), xFrames, yFrames);
}
export function drawSprite(
ctx: CanvasRenderingContext2D,
sprite: Sprite,