AB3: BodyLinkedList working

This commit is contained in:
2022-03-31 19:50:10 +02:00
parent cf4c1ad9d0
commit f24ad9bcaf
7 changed files with 252 additions and 51 deletions

View File

@ -81,7 +81,7 @@ public class Simulation {
// merge bodies that have collided
for (int i = 0; i < bodies.length; i++) {
for (int j = i + 1; j < bodies.length; j++) {
if (bodies[j].distanceTo(bodies[i]) < bodies[j].radius() + bodies[i].radius()) {
if (bodies[j].collidesWith(bodies[i])) {
bodies[i] = bodies[i].merge(bodies[j]);
Body[] bodiesOneRemoved = new Body[bodies.length - 1];
for (int k = 0; k < bodiesOneRemoved.length; k++) {