(index: number)
| 192 | shapes[5] = new Edge({ x: -1.0, y: 0.0 }, { x: 1.0, y: 0.0 }); |
| 193 | |
| 194 | function createBody(index: number) { |
| 195 | if (bodies.length > MAX_BODIES) { |
| 196 | world.destroyBody(bodies.shift()!); |
| 197 | } |
| 198 | |
| 199 | const body = world.createBody({ |
| 200 | type: "static", |
| 201 | position: { |
| 202 | x: Math.random() * 20 - 10, |
| 203 | y: Math.random() * 20, |
| 204 | }, |
| 205 | angle: Math.random() * 2 * Math.PI - Math.PI, |
| 206 | userData: index, |
| 207 | angularDamping: index === 4 ? 0.02 : 0, |
| 208 | }); |
| 209 | |
| 210 | const shape = shapes[index % shapes.length]; |
| 211 | |
| 212 | body.createFixture({ |
| 213 | shape: shape, |
| 214 | friction: 0.3, |
| 215 | }); |
| 216 | |
| 217 | bodies.push(body); |
| 218 | } |
| 219 | |
| 220 | function destroyBody() { |
| 221 | const body = bodies.shift(); |
no test coverage detected