I fixed the “merging from hell”. The first issue was the radius calculation. When two circles merge, simply adding their radii (r1 + r2) is physically wrong because the combined area grows way too fast. In reality, the area of the circles should add up: A_new = A1 + A2. By plugging in the area formula π × r², we get π × r_new² = (π × r1²) + (π × r2²). The π cancels out completely, leaving r_new = math.sqrt(r1² + r2²). I updated the collision code with this, and now the combined masses have physically accurate sizes.To make this look right, I also fixed the visual scaling issue. Previously, every particle rendered at shapesize(1, 1) regardless of its actual mass or radius. I changed the instantiator so that a body’s shapesize dynamically scales with its physics radius: self.turt.shapesize(self.radius / 10, self.radius / 10). Now when objects collide, you can actually see the merged planet grow on the screen.Lastly, I added a quick reset button. Pressing the R key runs a function that loops through the current objects, hides all their turtles to prevent visual ghosts, clears the main objects list, resets the camera back to center coordinates, and spawns a fresh central star
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.