Pre-existing classes: SmoothMover, Vector
i want to use a combination of vector and smoothmover to take a starting position (x,y), then add an object in a random direction, but at a set distance
then i want to repeat, replacing the original position with the position of the last object added.
the result would be a winding (or completely random) chain of objects each the same distance away from the last one
this is a sample of the code, snipped for clarity.
cycling reset about 10 times, i see situations like 1 planet but it's far, 2 planets and one is almost where i want it, but the 2nd is really far away, or no planets at all.
I'm pretty sure i'm using vector wrong, my math is weak and this is a new concept for me. i'm not asking anyone to write my code ;) just, if they could, point out the obvious error i'm not seeing.
in the meantime i'll be plugging away. if i figure it out, i'll repost.
public Space() { super(960, 620, 1, false); myShip = new SpaceShip(20, 8, new Vector(0,1.0)); addObject(myShip, getWidth() / 2, getHeight() / 2); vtr = new Vector((double)myShip.getX(),(double)myShip.getY()); vtr.setDirection(Greenfoot.getRandomNumber(359)); spaceOutPlanets(); } public void spaceOutPlanets() { for (int i = 0; i < 5; i++) { addObject(new Planet() (int)vtr.getX(),(int)vtr.getY()); updateVtr(); } } public void updateVtr() { vtr.setDirection(Greenfoot.getRandomNumber(359)); }