From 6d13f86209ae4b962a03d805e5d23bcddb75232e Mon Sep 17 00:00:00 2001 From: kts of kettek Date: Sun, 30 Jan 2022 00:37:11 -0800 Subject: [PATCH] Add world border --- Engine/src/states/Game.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Engine/src/states/Game.ts b/Engine/src/states/Game.ts index 87caf6a..b8b99bc 100644 --- a/Engine/src/states/Game.ts +++ b/Engine/src/states/Game.ts @@ -108,6 +108,13 @@ export function GameState(ctx: ContextI): StateI { // Load the world segment. let w = segments.world if (!w) return ctx.pop() + + // Add our world border. + let borderShape = planck.Chain([planck.Vec2(0, 0), planck.Vec2(w.width, 0), planck.Vec2(w.width, w.height), planck.Vec2(0, w.height), planck.Vec2(0, 0)]) + let borderFixture = worldBody.createFixture({ + shape: borderShape, + }) + rootContainer.width = w.width rootContainer.height = w.height rootContainer.scale.set(2, 2) @@ -174,6 +181,8 @@ export function GameState(ctx: ContextI): StateI { // Add fake others addEntity(new AnimalEntity(animals.turkey), 'objects', 200, 200) + addEntity(new AnimalEntity(animals.nutria), 'objects', Math.random()*w.width, Math.random()*w.height) + addEntity(new AnimalEntity(animals.deer), 'objects', Math.random()*w.width, Math.random()*w.height) ctx.app.stage.addChild(rootContainer) }