I have been making a game and have used rotations to create parts of it. I am trying to figure out how to determine whether a line that is always at a certain point that is just being rotated, can hit something that is not being rotated and is moving. Here's the coding without all the variable beginnings-

*void setup(){*

size(750,750);

smooth();

x1 = 0;

y1 = 0;

s1 = 40;

s2 = 20;

s3 = 15;

x2 = 0;

y2 = -10;

r = 0;

shot = false;

ex1 = random(5,745);

ey1 = 0;

ey2 = ey1 - 10;

ex2 = ex1 - 30;

ex3 = ex1 + 30;

ey3 = ey1 + 20;

es1 = 2;

es2 = 2;

b = 5;

nb = 0;

exsp = (375 - ex1) / 375;

eysp =1;

Explosion = loadImage("ifwt-explosion.jpg");

op = 255;

destroyed = false;

}

void mouseClicked(){

translate(375,375);

pushMatrix();

rotate(radians(r));

shot = true;

stroke(150,150,0);

strokeWeight(5);

line(0,-25,0,-750);

popMatrix();

}

void draw(){

background(0);

if(keyPressed){

if(key == 'A' || key == 'a'){

r -= 2;

}

if(key == 'D' || key == 'd'){

r += 2;

}

}

if(r >= 360 || r <= -360){

r = 0;

}

pushMatrix();

translate(375,375);

rotate(radians(r));

fill(240);

stroke(255,0,0);

strokeWeight(1);

ellipse(x1,y1,s1,s1);

fill(0,255,255);

ellipse(x2,y2,s2,s3);

popMatrix();

constrain(b,0,20);

stroke(50,op);

fill(150,op);

ellipse(ex1,ey1,20,20);

stroke(150,0,0,op);

strokeWeight(b);

noFill();

ellipse(ex1,ey1,es1,es2);

b = noise(nb) * 20;

nb += .02;

if(ey1 > 385){

destroyed = true;

}

if(destroyed == true){

op = 255;

ex1 = random(5,745);

ey1 =0;

exsp = (375 - ex1) / 375;

eysp =1;

destroyed = false;

}

ex1 += exsp;

ey1 += eysp;

if(dist(ex1,ey1,375,375) < 20){

imageMode(CENTER);

image(Explosion, 375,375);

op = 0;

}

}size(750,750);

smooth();

x1 = 0;

y1 = 0;

s1 = 40;

s2 = 20;

s3 = 15;

x2 = 0;

y2 = -10;

r = 0;

shot = false;

ex1 = random(5,745);

ey1 = 0;

ey2 = ey1 - 10;

ex2 = ex1 - 30;

ex3 = ex1 + 30;

ey3 = ey1 + 20;

es1 = 2;

es2 = 2;

b = 5;

nb = 0;

exsp = (375 - ex1) / 375;

eysp =1;

Explosion = loadImage("ifwt-explosion.jpg");

op = 255;

destroyed = false;

}

void mouseClicked(){

translate(375,375);

pushMatrix();

rotate(radians(r));

shot = true;

stroke(150,150,0);

strokeWeight(5);

line(0,-25,0,-750);

popMatrix();

}

void draw(){

background(0);

if(keyPressed){

if(key == 'A' || key == 'a'){

r -= 2;

}

if(key == 'D' || key == 'd'){

r += 2;

}

}

if(r >= 360 || r <= -360){

r = 0;

}

pushMatrix();

translate(375,375);

rotate(radians(r));

fill(240);

stroke(255,0,0);

strokeWeight(1);

ellipse(x1,y1,s1,s1);

fill(0,255,255);

ellipse(x2,y2,s2,s3);

popMatrix();

constrain(b,0,20);

stroke(50,op);

fill(150,op);

ellipse(ex1,ey1,20,20);

stroke(150,0,0,op);

strokeWeight(b);

noFill();

ellipse(ex1,ey1,es1,es2);

b = noise(nb) * 20;

nb += .02;

if(ey1 > 385){

destroyed = true;

}

if(destroyed == true){

op = 255;

ex1 = random(5,745);

ey1 =0;

exsp = (375 - ex1) / 375;

eysp =1;

destroyed = false;

}

ex1 += exsp;

ey1 += eysp;

if(dist(ex1,ey1,375,375) < 20){

imageMode(CENTER);

image(Explosion, 375,375);

op = 0;

}

}

1