WIP
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { box } from "#/engine/Box";
|
import { box } from "#/engine/Box.ts";
|
||||||
import { defineEntity } from "#/engine/Entity.ts";
|
import { defineEntity } from "#/engine/Entity.ts";
|
||||||
import { createSpriteAnimation, useSpriteSheetSrc } from "#/engine/Sprite.ts";
|
import { createSpriteAnimation, useSpriteSheetSrc } from "#/engine/Sprite.ts";
|
||||||
import { createVector } from "#/engine/Vector.ts";
|
import { createVector } from "#/engine/Vector.ts";
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { type Box, box } from "#/engine/Box.ts";
|
||||||
import { defineEntity } from "#/engine/Entity.ts";
|
import { defineEntity } from "#/engine/Entity.ts";
|
||||||
import {
|
import {
|
||||||
createSpriteAnimation,
|
createSpriteAnimation,
|
||||||
@@ -39,7 +40,7 @@ const animations = {
|
|||||||
|
|
||||||
const process = defineEntity<{
|
const process = defineEntity<{
|
||||||
position: Vector;
|
position: Vector;
|
||||||
$animation: { value: SpriteAnimation };
|
animation: Box<SpriteAnimation>;
|
||||||
animations: {
|
animations: {
|
||||||
idle: SpriteAnimation;
|
idle: SpriteAnimation;
|
||||||
walk: SpriteAnimation;
|
walk: SpriteAnimation;
|
||||||
@@ -52,7 +53,7 @@ const process = defineEntity<{
|
|||||||
stuff: number;
|
stuff: number;
|
||||||
}>("testEntity", {
|
}>("testEntity", {
|
||||||
position: createVector(),
|
position: createVector(),
|
||||||
$animation: { value: animations.idle },
|
animation: box(animations.idle),
|
||||||
animations,
|
animations,
|
||||||
sprite: sprites.idle,
|
sprite: sprites.idle,
|
||||||
sprites,
|
sprites,
|
||||||
@@ -63,11 +64,11 @@ process((entity, _delta) => {
|
|||||||
entity.position.x += entity.stuff * 0.5;
|
entity.position.x += entity.stuff * 0.5;
|
||||||
if (entity.position.x > viewport.canvas.width - 16) {
|
if (entity.position.x > viewport.canvas.width - 16) {
|
||||||
entity.stuff = -1;
|
entity.stuff = -1;
|
||||||
entity.$animation.value = entity.animations.walk;
|
entity.animation.value = entity.animations.walk;
|
||||||
entity.sprite = entity.sprites.walk;
|
entity.sprite = entity.sprites.walk;
|
||||||
} else if (entity.position.x < 0) {
|
} else if (entity.position.x < 0) {
|
||||||
entity.stuff = 1;
|
entity.stuff = 1;
|
||||||
entity.$animation.value = entity.animations.idle;
|
entity.animation.value = entity.animations.idle;
|
||||||
entity.sprite = entity.sprites.idle;
|
entity.sprite = entity.sprites.idle;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user