From 5eae6f29a80cd47e268cb6eaefa96a0ab0a63e54 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 8 Nov 2018 22:03:08 +0100 Subject: Implement more flexible handling of entities and collidables --- src/view/entity.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/view') diff --git a/src/view/entity.ts b/src/view/entity.ts index 6241387..421a238 100644 --- a/src/view/entity.ts +++ b/src/view/entity.ts @@ -1,16 +1,16 @@ +import { EntityData } from '../model/data/entity'; import { Renderer } from './renderer/renderer'; import { SpriteView, SpriteViewBuilder } from './sprite'; import { loadImage, mkTexture } from './util/image'; -export async function loadSimpleEntity( +export async function loadEntity( r: Renderer, - sprite: string, - anchor: [number, number] = [0.5, 0.5], + data: EntityData, ): Promise { - const tile = await loadImage(`resources/sprite/entity/${sprite}.png`); + const tile = await loadImage(`resources/sprite/entity/${data.sprite}.png`); const texture = mkTexture(r.getContext(), tile); - const [x, y] = anchor; + const [x, y] = data.anchor; const builder = new SpriteViewBuilder(r, texture); builder.addSprite([-x, -y, -x + 1, -y + 1], [0, 0, 1, 1]); -- cgit v1.2.3