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, Circle, Box, Testbed } from "planck";
|
2017-03-11 02:55:31 -05:00
|
|
|
|
2024-12-24 15:07:16 +03:30
|
|
|
const world = new World();
|
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.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);
|
2017-03-11 02:55:31 -05:00
|
|
|
|
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({
|
2024-12-15 13:30:32 +03:30
|
|
|
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,
|
|
|
|
|
});
|
2023-07-31 21:47:06 -07:00
|
|
|
}
|
2017-03-11 02:55:31 -05:00
|
|
|
|
2024-12-18 14:18:45 +03:30
|
|
|
const box = world.createBody({
|
2024-12-15 13:30:32 +03:30
|
|
|
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 },
|
2017-03-11 02:55:31 -05:00
|
|
|
});
|
2023-07-31 21:47:06 -07:00
|
|
|
|
2024-12-24 19:58:07 +03:30
|
|
|
box.createFixture({
|
|
|
|
|
shape: new Box(1.5, 1.5),
|
|
|
|
|
density: 1.0,
|
|
|
|
|
});
|