Add world border
This commit is contained in:
parent
295e27f83c
commit
6d13f86209
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user