59 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

/*
2024-11-23 16:32:23 +03:30
* Copyright (c) Erin Catto
* Licensed under the MIT license
*/
2024-12-23 18:24:21 +03:30
import { World, Edge, Box, Testbed } from "planck";
2024-12-24 15:07:16 +03:30
const world = new World({
gravity: { x: 0, y: -10 },
});
2023-08-20 03:24:33 -07:00
const testbed = Testbed.mount();
testbed.start(world);
2024-12-18 14:18:45 +03:30
const COUNT = 20;
2024-12-24 15:07:16 +03:30
const ground = world.createBody({
type: "static",
});
2024-12-24 19:58:07 +03:30
ground.createFixture({
shape: new Edge({ x: -40.0, y: 0.0 }, { x: 40.0, y: 0.0 }),
density: 0.0,
});
2024-12-18 14:18:45 +03:30
const a = 0.5;
const box = new Box(a, a);
2024-12-23 18:24:21 +03:30
const x = { x: -7.0, y: 0.75 };
const y = { x: 0, y: 0 };
const deltaX = { x: 0.5625, y: 1.25 };
const deltaY = { x: 1.125, y: 0.0 };
2023-08-14 13:59:23 -07:00
for (let i = 0; i < COUNT; ++i) {
2024-12-23 18:24:21 +03:30
y.x = x.x;
y.y = x.y;
2023-08-14 13:59:23 -07:00
for (let j = i; j < COUNT; ++j) {
2024-12-24 15:07:16 +03:30
const body = world.createBody({
type: "dynamic",
position: y,
});
2024-12-24 19:58:07 +03:30
body.createFixture({
shape: box,
density: 5.0,
});
2024-12-23 18:24:21 +03:30
y.x += deltaY.x;
y.y += deltaY.y;
}
2024-12-23 18:24:21 +03:30
x.x += deltaX.x;
x.y += deltaX.y;
}
testbed.step = function () {
2023-08-14 13:59:23 -07:00
// let tree = world.m_broadPhase.m_tree;
// if (stepCount++ == 400) {
// tree.rebuildBottomUp();
// }
};