39 lines
742 B
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, Body, Edge, Circle, 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 = 10;
const bodies: Body[] = [];
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 circle = new Circle(1.0);
2023-08-14 13:59:23 -07:00
for (let i = 0; i < COUNT; ++i) {
2024-12-24 15:07:16 +03:30
bodies[i] = world.createBody({
type: "dynamic",
position: { x: 0.0, y: 4.0 + 3.0 * i },
2024-12-24 19:58:07 +03:30
linearVelocity: { x: 0.0, y: -50.0 },
});
bodies[i].createFixture({
shape: circle,
density: 1.0,
2024-12-24 15:07:16 +03:30
});
}