I need to reconsider the delta thing

This commit is contained in:
kolaflash
2025-11-28 12:13:31 +01:00
parent 37fe43d8e9
commit ad9ab70d05
3 changed files with 58 additions and 37 deletions
+8 -10
View File
@@ -4,8 +4,8 @@ export type Sprite = {
yFrames: number;
frameWidth: number;
frameHeight: number;
x: number;
y: number;
xIndex: number;
yIndex: number;
};
export function createSprite(
@@ -19,8 +19,8 @@ export function createSprite(
yFrames,
frameWidth: image.width / xFrames,
frameHeight: image.height / yFrames,
x: 0,
y: 0,
xIndex: 0,
yIndex: 0,
};
}
@@ -29,18 +29,16 @@ export function drawSprite(
sprite: Sprite,
x: number,
y: number,
width: number,
height: number,
): void {
ctx.drawImage(
sprite.image,
sprite.x,
sprite.y,
sprite.xIndex * sprite.frameWidth,
sprite.yIndex * sprite.frameHeight,
sprite.frameWidth,
sprite.frameHeight,
x,
y,
width,
height,
sprite.frameWidth,
sprite.frameHeight,
);
}