I am working on a game that's similar to Missile Command (in fact, it was supposed to be Missile Command, but I got stuck in a loop that wouldn't let me do anything else until the missile was done being drawn, and I'd have to re-do the whole game to fix that and I don't have time. If anyone wants to help me with that instead, that'd be awesome

). Essentially, you click and a line appears, and everything that runs into it blows up. I'm not exactly sure how to do the collision there, because you need to follow up the slope of the line and I find the slope by y2-y1/x2-x1. By the end, the whole slope is found, but I'm not sure how to have it actually know where the line is, as opposed to a box with the line in it.

Here's my draw method:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| public void draw(int _x3,int x, int y, Graphics g) { double x3=(double)_x3; MissileCommand Commander = new MissileCommand(); Graphics2D g2D=(Graphics2D)g; if(x>=x3) { m=((double)y/((double)x-x3)); System.out.println("Slope: "+m+"X change?: "+x); double m2=m; x2=x3+1; x+=x3; while(m<=y && x2<=x ) { Shape liney = new Line2D.Double(x3,0,x2,m); g2D.draw(liney); Commander.delay(); x2++; m+=m2; System.out.println("Far: "+Far); } x-=x3; }
if(x><x3) { m=(Math.abs((double)y/((double)x-x3))); if(m==0) m++; double m2=m; { shape liney = new line2d.double(x3,0,x2,m); g2d.draw(liney); commander.delay(); x2--; m+=m2; system.out.println("other far: "+far); } } } |

any help would be greatly appreciated, thanks.>