From 37fe43d8e9675f0b84f711c42d86f4649eaca5eb Mon Sep 17 00:00:00 2001 From: kolaflash Date: Fri, 28 Nov 2025 00:25:32 +0100 Subject: [PATCH] WIP --- entities/testEntity/index.ts | 11 ++++++----- scenes/testScene/data.json | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/entities/testEntity/index.ts b/entities/testEntity/index.ts index 7da2df1..8d0cfec 100644 --- a/entities/testEntity/index.ts +++ b/entities/testEntity/index.ts @@ -1,4 +1,5 @@ import { useEntity } from "#/engine/Entity.ts"; +import { viewport } from "#/engine/Viewport.ts"; import { loadImage } from "#/lib/loadImage.ts"; import { createSprite, drawSprite } from "#/lib/Sprite.ts"; @@ -17,10 +18,10 @@ animate((entity, ctx, _delta) => { }); process((entity, _delta) => { - if (entity.state.stuff === 1) { - entity.position.x += 1; - if (entity.position.x > 164) { - entity.state.stuff = 0; - } + entity.position.x += entity.state.stuff; + if (entity.position.x > viewport.canvas.width - 16) { + entity.state.stuff = -1; + } else if (entity.position.x < 0) { + entity.state.stuff = 1; } }); diff --git a/scenes/testScene/data.json b/scenes/testScene/data.json index 634646a..79c9ae1 100644 --- a/scenes/testScene/data.json +++ b/scenes/testScene/data.json @@ -1,6 +1,6 @@ { "id": "testScene", - "width": 180, + "width": 80, "height": 48, "entities": [ {