We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Re: Guys I need really quick help, assignment......
Page Index Toggle Pages: 1
Re: Guys I need really quick help, assignment...... (Read 748 times)
Re: Guys I need really quick help, assignment......
Nov 27th, 2009, 11:52am
 
As usual for homework (thanks for being honest about it!), we suggest to show what you have done so far, and we help in getting it working...

I suppose you know how to declare arrays of size 50.
And to store mouse coordinates at the bottom of the array. (Hint: do that in mouseMoved() function.)
Drawing the shape shouldn't be too hard if you follow the reference.

To move up coordinates, you have start the loop at the top (the highest index) and go down, copying each time from i to i+1 (beware of bounds!).
Re: Guys I need really quick help, assignment......
Reply #1 - Nov 27th, 2009, 12:01pm
 
void setup() {
 size (100,100);
 smooth();
 noStroke();
 {
 float x = mouseX;
 float y = mouseY;
 }
 {
 int[] y = new int[50];
 int[] x = new int[50];
 }
}


void draw () {
 frameRate(10);
 if (mousePressed==true) {
 println(mouseX + ";" + mouseY);
}
if (mousePressed==true) {
 draw();
 point(mouseY, mouseX);
}
beginShape();
{
  for (int i=0 ; i<50; i++)
vertex(mouseX, mouseY);
}
endShape();
}

this is what i have and it doesn't make too much sense at all, and is basically void of any functionality.
Re: Guys I need really quick help, assignment......
Reply #2 - Nov 27th, 2009, 12:02pm
 
if you got what PhiLho mentioned, and are stuck at the array/coordinate storing, maybe take a look at this sketch that uses something similar

http://processing.org/discourse/yabb2/?num=1258658941
Re: Guys I need really quick help, assignment......
Reply #3 - Nov 27th, 2009, 12:34pm
 
i am confused. what happend to the threat Smiley  Cheesy anyway i can tell there is a lot of mess in your sketch, i will comment it and post again
Re: Guys I need really quick help, assignment......
Reply #4 - Nov 27th, 2009, 12:40pm
 
Quote:
void setup() {
 size (100,100);
 smooth();
 noStroke(); //if you call nostroke and use point you wont see anything
 { //remove make no sense
 float x = mouseX; //variables need to be declared outside setup
 float y = mouseY; // "
 } //remove
 {//remove
 int[] y = new int[50]; // same here, if declared in setup cant be read outside.
 int[] x = new int[50]; //  read this for more info http://processing.org/learning/basics/variablescope.html
 }//remove
}


void draw () {
 frameRate(10); // put that in setup if needed
 if (mousePressed==true) {
 println(mouseX + ";" + mouseY);
}
if (mousePressed==true) {
 draw(); // what is this ?
 point(mouseY, mouseX); // use either point or vertex. in this case vertex cause you want a connected line.
}
// you totally miss the part where you store your variables into the array and s
witch it. 

// take a look at the example i posted. 

beginShape();
{
  for (int i=0 ; i<50; i++)
vertex(mouseX, mouseY);  // here read the coordinates of your stored arrays like vertex(x[i],y[i]);
}
endShape();
}

Page Index Toggle Pages: 1