Rename playback to animation again

This commit is contained in:
Schluffe
2026-03-15 12:29:57 +01:00
parent 575884d15b
commit 650b28a660
5 changed files with 30 additions and 30 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ import { pointer } from "#/engine/Pointer.ts";
import $ from "#/engine/Scene.ts";
import {
createSprite,
createSpritePlayback,
createSpriteAnimation,
defineSpriteSheet,
} from "#/engine/Sprite.ts";
import { createVector, type Vector } from "#/engine/Vector.ts";
@@ -16,7 +16,7 @@ const idleSrc = await defineSpriteSheet(charIdle, 2, 4);
const process = defineEntity("hero", {
position: createVector(),
sprite: createSprite(idleSrc),
playback: createSpritePlayback(500, 2),
animation: createSpriteAnimation(500, 2),
velocity: createVector(),
});
+2 -2
View File
@@ -1,7 +1,7 @@
import { defineEntity } from "#/engine/Entity.ts";
import {
createSprite,
createSpritePlayback,
createSpriteAnimation,
defineSpriteSheet,
} from "#/engine/Sprite.ts";
import { createVector } from "#/engine/Vector.ts";
@@ -12,5 +12,5 @@ const portalSrc = await defineSpriteSheet(portal, 3, 1);
defineEntity("portal", {
position: createVector(),
sprite: createSprite(portalSrc),
playback: createSpritePlayback(400, 0),
animation: createSpriteAnimation(400, 0),
});
+14 -14
View File
@@ -1,10 +1,10 @@
import { defineEntity } from "#/engine/Entity.ts";
import $ from "#/engine/Scene.ts";
import {
createSpritePlayback,
createSpriteAnimation,
defineSpriteSheet,
type Sprite,
type SpritePlayback,
type SpriteAnimation,
} from "#/engine/Sprite.ts";
import { createVector, type Vector } from "#/engine/Vector.ts";
import { viewport } from "#/engine/Viewport.ts";
@@ -33,17 +33,17 @@ const sprites = {
},
};
const playbacks = {
idle: createSpritePlayback(500, 2),
walk: createSpritePlayback(250, 2),
const animations = {
idle: createSpriteAnimation(500, 2),
walk: createSpriteAnimation(250, 2),
};
const process = defineEntity<{
position: Vector;
playback: SpritePlayback;
playbacks: {
idle: SpritePlayback;
walk: SpritePlayback;
animation: SpriteAnimation;
animations: {
idle: SpriteAnimation;
walk: SpriteAnimation;
};
sprite: Sprite;
sprites: {
@@ -53,8 +53,8 @@ const process = defineEntity<{
stuff: number;
}>("testEntity", {
position: createVector(),
playback: playbacks.idle,
playbacks: playbacks,
animation: animations.idle,
animations: animations,
sprite: sprites.idle,
sprites,
stuff: 1,
@@ -64,16 +64,16 @@ process((id, _delta) => {
const position = $<Vector>("position").get(id)!;
const stuff = $<number>("stuff").get(id)!;
const sprite = $<Sprite>("sprite").get(id)!;
const playback = $<SpritePlayback>("playback").get(id)!;
const animation = $<SpriteAnimation>("animation").get(id)!;
position.value.x += stuff.value * 0.5;
if (position.value.x > viewport.canvas.width - 16) {
stuff.value = -1;
playback.value = playbacks.walk;
animation.value = animations.walk;
sprite.value = sprites.walk;
} else if (position.value.x < 0) {
stuff.value = 1;
playback.value = playbacks.idle;
animation.value = animations.idle;
sprite.value = sprites.idle;
}
});