CodingTrain / asteroids-advanced

24 stars 7 forks source link

Refine asteroid splitting #9

Closed MunWolf closed 7 years ago

MunWolf commented 7 years ago

Make the asteroid splitting look more realistic by using the algorithm me and @NaveTK worked on in Gitter chat.

NaveTK commented 7 years ago

I'm on it, should be done in a couple of hours

JonathanHHenson commented 7 years ago

This code would run at the start of the Asteroid constructor to break up any splinter shaped asteroids

IF (A > minArea) {
  Error = |(PI - A / r ^ 2) / PI|
  IF (Error > Accepted) Snap()
} ELSE {
  dead = true
}

Snap will split the asteroid at the point which is closest to another point at least 2 indexes away.

JonathanHHenson commented 7 years ago

Done