Meh
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import charIdle from "#/assets/char-idle.png";
|
||||
import { useEntity } from "#/engine/Entity.ts";
|
||||
import { animateSprite, createAnimation } from "#/lib/Animation.ts";
|
||||
import { fromSrc, type Sprite } from "#/lib/Sprite.ts";
|
||||
|
||||
const idle: Sprite = await fromSrc(charIdle, 2, 4);
|
||||
|
||||
const { animate, process } = useEntity("fooEntity", {
|
||||
animation: createAnimation(2, 500),
|
||||
});
|
||||
|
||||
animate((entity, ctx, delta) => {
|
||||
animateSprite(
|
||||
ctx,
|
||||
idle,
|
||||
entity.animation,
|
||||
entity.position.x,
|
||||
entity.position.y,
|
||||
delta,
|
||||
);
|
||||
});
|
||||
|
||||
process((entity, delta) => {});
|
||||
@@ -1,3 +1,5 @@
|
||||
import charIdle from "#/assets/char-idle.png";
|
||||
import charWalk from "#/assets/char-walk.png";
|
||||
import { useEntity } from "#/engine/Entity.ts";
|
||||
import { viewport } from "#/engine/Viewport.ts";
|
||||
import {
|
||||
@@ -9,8 +11,8 @@ import { loadImage } from "#/lib/loadImage.ts";
|
||||
import { createSprite } from "#/lib/Sprite.ts";
|
||||
|
||||
const sprites = {
|
||||
idle: createSprite(await loadImage("/assets/char-idle.png"), 2, 4),
|
||||
walk: createSprite(await loadImage("/assets/char-walk.png"), 4, 4),
|
||||
idle: createSprite(await loadImage(charIdle), 2, 4),
|
||||
walk: createSprite(await loadImage(charWalk), 4, 4),
|
||||
};
|
||||
|
||||
const { animate, process } = useEntity<{
|
||||
|
||||
Reference in New Issue
Block a user