From 125b3c7897f7534fecdd50cdbdae935e8bd3c930 Mon Sep 17 00:00:00 2001 From: kts of kettek Date: Sat, 29 Jan 2022 05:18:51 -0800 Subject: [PATCH] Add camera edge clamping --- Engine/src/states/Game.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/src/states/Game.ts b/Engine/src/states/Game.ts index a03eeb6..334d840 100644 --- a/Engine/src/states/Game.ts +++ b/Engine/src/states/Game.ts @@ -141,7 +141,7 @@ export function GameState(ctx: ContextI): StateI { entity.act(desiredActions) // FIXME: This isn't the right place for this. rootContainer.position.set(Math.round(ctx.app.renderer.width/2), Math.round(ctx.app.renderer.height/2)) - rootContainer.pivot.set(entity.x, entity.y) + rootContainer.pivot.set(Math.max(rootContainer.width/6, Math.min(entity.x, rootContainer.width/3)), Math.max(rootContainer.height/6, Math.min(entity.y, rootContainer.height/3))) } entity.update(delta) }