43 lines
746 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, Circle, Box, Testbed } from "planck";
2024-12-24 15:07:16 +03:30
const world = new World();
2023-08-20 03:24:33 -07:00
const testbed = Testbed.mount();
testbed.y = 0;
testbed.hz = 60;
testbed.speed = 1;
testbed.start(world);
2018-10-20 23:34:22 -07:00
2024-12-18 14:18:45 +03:30
const circle = new Circle(0.1);
2023-08-14 13:59:23 -07:00
for (let i = 0; i < 50; ++i) {
2024-12-18 14:18:45 +03:30
const b = world.createBody({
type: "dynamic",
2024-12-23 18:24:21 +03:30
position: {
x: Math.random() * -6,
y: Math.random() * 2 - 1,
},
2023-08-14 13:59:23 -07:00
});
2024-12-24 19:58:07 +03:30
b.createFixture({
shape: circle,
density: 0.01,
});
}
2024-12-18 14:18:45 +03:30
const box = world.createBody({
type: "dynamic",
bullet: true,
2024-12-24 19:58:07 +03:30
position: { x: -40.0, y: 0.0 },
linearVelocity: { x: 100.0, y: 0.0 },
});
2024-12-24 19:58:07 +03:30
box.createFixture({
shape: new Box(1.5, 1.5),
density: 1.0,
});