34 lines
650 B
TypeScript
Raw Permalink Normal View History

2024-12-23 18:24:21 +03:30
import { World, Edge, Box, Testbed } from "planck";
2016-03-23 22:59:54 -04:00
2024-12-24 15:07:16 +03:30
const world = new World({
gravity: { x: 0, y: -10 },
});
2016-03-23 22:59:54 -04:00
2023-08-20 03:24:33 -07:00
const testbed = Testbed.mount();
testbed.start(world);
2016-03-23 22:59:54 -04:00
2024-12-24 15:07:16 +03:30
const bar = world.createBody({
type: "static",
2024-12-24 19:58:07 +03:30
angle: 0.2,
});
bar.createFixture({
shape: new Edge({ x: -20, y: 5 }, { x: 20, y: 5 }),
2024-12-24 15:07:16 +03:30
});
2016-03-23 22:59:54 -04:00
2023-08-14 13:59:23 -07:00
for (let i = -2; i <= 2; i++) {
for (let j = -2; j <= 2; j++) {
2024-12-24 15:07:16 +03:30
const box = world.createBody({
type: "dynamic",
position: { x: i * 1, y: -j * 1 + 20 },
});
box.setMassData({
mass: 1,
2024-12-23 18:24:21 +03:30
center: { x: 0, y: 0 },
I: 1,
2023-08-14 13:59:23 -07:00
});
2024-12-24 19:58:07 +03:30
box.createFixture({
shape: new Box(0.5, 0.5),
});
}
}