Skip to content
Advertisement

Create a “tail” for an object that is orbiting

Edit

Here is a JSFiddle with the code for the “tail” function commenting out.Solar System JSFiddle

I have this object I am working on that has an object orbiting a center mass. That works perfectly. small red planet orbiting sun

I am now trying to add a trailing line or “tail” that follows behind the planet. My tail object looks like this:

JavaScript

The addPoint function takes an object that looks like ‘{x: currentX, y: currentY} currentX and currentY are the x and y point of the object when ever it gets called.

I am lost on how I need to add the point to the points array and then draw based on those coordinates.

Advertisement

Answer

I modified your version to working condition

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement