d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Processing Help - Uni Course > Basic Form Of Java
Add Reply New Topic New Poll
Member
Posts: 9,710
Joined: May 11 2008
Gold: 550.69
Mar 11 2013 07:06pm
doing an assignment that requires me to join two circles by a line, with circles drawn one at a time by mouse click

the coordinates for the circle are variables

i am having trouble trying to find the coordinates for the previous circle in which to connect the line

eg

line(previous circleX, previous circleY, circleX, circleY);

any help or advice would be greatly appreciated

also i can post entire code if that helps
Member
Posts: 2,757
Joined: Nov 26 2007
Gold: 1,214.81
Mar 12 2013 08:20am
Code
boolean firstClick=true;
int previousX;
int previousY;

public void mousePressed(MouseEvent event) { }{
if(firstClick){
previousX = event.getX();
previousY = event.getY();
firstClick=false;
} else{
line(previousX,previousY,event.getX(),event.getY());
firstClick=true;
}
}


This post was edited by labatymo on Mar 12 2013 08:24am
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll