import { Renderer } from './renderer/renderer'; import { SpriteView, SpriteViewBuilder } from './sprite'; import { loadImage, mkTexture } from './util/image'; export async function loadSimpleEntity( r: Renderer, sprite: string, anchor: [number, number] = [0.5, 0.5], ): Promise { const tile = await loadImage(`resources/sprite/entity/${sprite}.png`); const texture = mkTexture(r.getContext(), tile); const [x, y] = anchor; const builder = new SpriteViewBuilder(r, texture); builder.addSprite([-x, -y, -x + 1, -y + 1], [0, 0, 1, 1]); return builder.build(); }