d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Yet Another Processing Exercise! :p
Add Reply New Topic New Poll
Member
Posts: 10,083
Joined: Aug 19 2007
Gold: 0.00
Oct 9 2014 07:54am
Yea so due to the amazing help I got from Blind[zF] i managed to get it to work :)

Now I stumbled into another issue that I just can't grasp.

Heres what I need the program to do:

Write a program that “records” mouse movement
when the mouse is pressed and playback the recorded
movement in a loop when the mouse is not pressed.
Hint: Use a 2D array where one dimension represents
recorded “frames” and the other dimension stores
location information.

Now I've managed to get it to record my coordinates when I drag the mouse, but I haven't been able to figure out how to make the ellipse follow the coordinates that it stored 1 by 1.
Right now it just sort of prints out an ellipse at every location :/

Here's my code so far;

Code
int num = 50;
int[] x = new int[num];
int[] y = new int[num];
boolean released = false;

void setup() {
size(600, 600);
noStroke();
smooth();
fill(255, 102);
}

void draw() {
background(0);
if (released==true){
for (int i = 0 ; i<50;i++){
ellipse(x[i],y[i],20,20);
}
released=false;
}

}


void mouseDragged(){
x[0] = mouseX;
y[0] = mouseY;
for (int i = num - 1; i > 0; i--) {
x[i] = x[i-1];
y[i] = y[i-1];
}



}

void mouseReleased(){
released=true;
}
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll