   Getting the a straight line
  Okay here is what I have I have a square that is my ship. The ship can move anywhere around the screen and rotate. I want to produce a straight line of particles to be gun. I have been racking my head on this for a while trying to figure out how I can emit the particles from a particular corner in a straignt line. I tried doing the following:p3   p2|----||||----|p1   p0I want the particles to come out of p3 in a straight line so I figured if I just found the slop of p0 to p3. I could just use that as my scaleing factor for each of the particles. So I computed the xscaling and yscaling points as followsxscale = p3.x-p0.x;yscale = p3.y-p0.y;Then I run though a loop of like ten particles each time adding the previous location to the current locationx =p3.x;y =p3.y;---loopparticle.x = x;particle.y = y;x += (xscale/40);y += (yscale/40);---end loopThis seemed to work pretty well but for some angles it just doesn't seem to work correcly the particles seem to come out a little off. Any advice is greatly appericated[edited by - l3arknight on February 19, 2004 9:16:51 PM][edited by - l3arknight on February 19, 2004 9:18:38 PM]
  Well, each corner has an X and Y value, so you just compute rise over run.If the particles need to be emitted from P3 then the equation is:slope = (P3.Y-P0.Y)/(P3.X-P0.X)Or, for particles coming out of P2:slope = (P2.Y-P1.Y)/(P2.X-P1.X)Then, for any particle that needs to travel on that line, you just increment X by 1 (or whatever value looks good) and compute Y like this:Y = slope*X+OriginYWhere OriginY is the Y value of the corner that the particle started from.   [edited by - JNewt on February 19, 2004 9:31:33 PM];  Thanks for the quick reply. I will give it a try.   [edited by - l3arknight on February 19, 2004 10:39:36 PM];  Oh, one thing I forgot: if the particle is emitted from either P3 or P1 (the left-side corners), X needs to be decremented   each turn because you want the particles to move towards the left edge of the screen. With P2 and P0, X should be incremented.Another thing that you can do for speed (though it's not a big deal) is precalculate the slope. If the rectangle's proportions remain the same throughout the game (you're not resizing it) then you can find the slope beforehand. Better yet, you only need to calculate one slope since the slope of the line through P3-P0 is just the negative of the slope of the line through P2-P1 and vice-versa.   [edited by - JNewt on February 20, 2004 11:09:46 AM]