2017-03-11 02:55:31 -05:00
|
|
|
/*
|
2024-11-23 16:32:23 +03:30
|
|
|
* Copyright (c) Erin Catto
|
2024-12-15 13:30:32 +03:30
|
|
|
* Licensed under the MIT license
|
2017-03-11 02:55:31 -05:00
|
|
|
*/
|
|
|
|
|
|
2024-12-23 18:24:21 +03:30
|
|
|
import { World, Body, Edge, Circle, Testbed } from "planck";
|
2017-03-11 02:55:31 -05:00
|
|
|
|
2024-12-24 15:07:16 +03:30
|
|
|
const world = new World({
|
|
|
|
|
gravity: { x: 0, y: -10 },
|
|
|
|
|
});
|
2017-03-11 02:55:31 -05:00
|
|
|
|
2023-08-20 03:24:33 -07:00
|
|
|
const testbed = Testbed.mount();
|
2023-07-31 21:47:06 -07:00
|
|
|
testbed.start(world);
|
2017-03-11 02:55:31 -05:00
|
|
|
|
2024-12-18 14:18:45 +03:30
|
|
|
const COUNT = 10;
|
|
|
|
|
const bodies: Body[] = [];
|
2017-03-11 02:55:31 -05:00
|
|
|
|
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,
|
|
|
|
|
});
|
2017-03-11 02:55:31 -05:00
|
|
|
|
2024-12-18 14:18:45 +03:30
|
|
|
const circle = new Circle(1.0);
|
2023-07-31 21:47:06 -07:00
|
|
|
|
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
|
|
|
});
|
2023-07-31 21:47:06 -07:00
|
|
|
}
|