Hello
I am having a problem with trying to connect dots ,everytime I click on a position with my mouse I create a dot and what is supposed to happen is that the dots get connected with a line. For this I need to save the previous x and y positions of my dot to connect it to the next dot.But I dont know how to save the previous position. Could anybody help me ?
</>
int dotX=-10;
int dotY=-10;
int prevDotX;
int prevDotY;
//Executed ONCE, at startup. Setup window size, framerate, etc.:
void setup()
{
size(500,500);
background(0);
}//Execution LOOP (60 times per second by default):
void draw()
{}
void drawDot(int size)
{
strokeWeight(size);
stroke(0,255,0);
point(dotX,dotY);
strokeWeight(5);
line(prevDotX,prevDotY,dotX,dotY);}
//Executed ONLY (but each time) mouse is pressed:
void mousePressed()
{
dotX=mouseX;
dotY=mouseY;
drawDot(10);}
//Executed ONLY (but each time) a key is pressed:
void keyPressed()
{}