<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Exercise 7-6: Parameter Passing</title>
	<atom:link href="http://www.learningprocessing.com/exercises/chapter-7/exercise-7-6/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learningprocessing.com</link>
	<description>A Beginner's Guide to Programming Images, Animation, and Interaction by Daniel Shiffman</description>
	<lastBuildDate>Thu, 09 Feb 2012 16:27:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Daniel Shiffman</title>
		<link>http://www.learningprocessing.com/exercises/chapter-7/exercise-7-6/comment-page-1/#comment-10161</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Sun, 21 Mar 2010 23:27:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1460#comment-10161</guid>
		<description>If the variable is not global, it is simply reset each time back to 50 and therefore never has the chance to increment.</description>
		<content:encoded><![CDATA[<p>If the variable is not global, it is simply reset each time back to 50 and therefore never has the chance to increment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick mimran</title>
		<link>http://www.learningprocessing.com/exercises/chapter-7/exercise-7-6/comment-page-1/#comment-10136</link>
		<dc:creator>Patrick mimran</dc:creator>
		<pubDate>Sat, 20 Mar 2010 11:54:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1460#comment-10136</guid>
		<description>Hello 

there is something i do not understand , 
i made my function called monDessin and i try to animate monDessin it only works when my variable is global , if i put movex inside myDessin no mouvement , why ?

Thanks you for your time 

Patrick

like in this code :
 float movex = 50 ;
void setup () {
  size ( 300 , 300 ) ;  
}
void draw () { 
 background ( 100 ) ;
  monDessin () ;
}
void monDessin () {
    fill ( random (0 , 255) , 100  , 200 ) ;
 movex = movex + 1 ;
    rect ( movex , 20 , 50 , 50 ) ;
    ellipse ( movex , 80 , 50 , 10 ) ;
  }

but if i move , movex inside myDessin function as below  it does not work , Why ?


void setup () {
  size ( 300 , 300 ) ;  
}
void draw () { 
 background ( 100 ) ;
  monDessin () ;
}
void monDessin () {

 float movex = 50 ;
    fill ( random (0 , 255) , 100  , 200 ) ;
 movex = movex + 1 ;
    rect ( movex , 20 , 50 , 50 ) ;
    ellipse ( movex , 80 , 50 , 10 ) ;
  }</description>
		<content:encoded><![CDATA[<p>Hello </p>
<p>there is something i do not understand ,<br />
i made my function called monDessin and i try to animate monDessin it only works when my variable is global , if i put movex inside myDessin no mouvement , why ?</p>
<p>Thanks you for your time </p>
<p>Patrick</p>
<p>like in this code :<br />
 float movex = 50 ;<br />
void setup () {<br />
  size ( 300 , 300 ) ;<br />
}<br />
void draw () {<br />
 background ( 100 ) ;<br />
  monDessin () ;<br />
}<br />
void monDessin () {<br />
    fill ( random (0 , 255) , 100  , 200 ) ;<br />
 movex = movex + 1 ;<br />
    rect ( movex , 20 , 50 , 50 ) ;<br />
    ellipse ( movex , 80 , 50 , 10 ) ;<br />
  }</p>
<p>but if i move , movex inside myDessin function as below  it does not work , Why ?</p>
<p>void setup () {<br />
  size ( 300 , 300 ) ;<br />
}<br />
void draw () {<br />
 background ( 100 ) ;<br />
  monDessin () ;<br />
}<br />
void monDessin () {</p>
<p> float movex = 50 ;<br />
    fill ( random (0 , 255) , 100  , 200 ) ;<br />
 movex = movex + 1 ;<br />
    rect ( movex , 20 , 50 , 50 ) ;<br />
    ellipse ( movex , 80 , 50 , 10 ) ;<br />
  }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Mimran</title>
		<link>http://www.learningprocessing.com/exercises/chapter-7/exercise-7-6/comment-page-1/#comment-9900</link>
		<dc:creator>Patrick Mimran</dc:creator>
		<pubDate>Fri, 12 Mar 2010 23:13:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1460#comment-9900</guid>
		<description>thank you

Patrick Mimran</description>
		<content:encoded><![CDATA[<p>thank you</p>
<p>Patrick Mimran</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Shiffman</title>
		<link>http://www.learningprocessing.com/exercises/chapter-7/exercise-7-6/comment-page-1/#comment-9893</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Fri, 12 Mar 2010 16:56:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1460#comment-9893</guid>
		<description>I think what you want to do is:

&lt;pre&gt;
void setup() {
  int val1 = multos(2,3);
  int val2 = multos(4,5);
  println(val1);
  println(val2);
}

int multos(int a, int b) {
  return a*b;
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I think what you want to do is:</p>
<pre>
void setup() {
  int val1 = multos(2,3);
  int val2 = multos(4,5);
  println(val1);
  println(val2);
}

int multos(int a, int b) {
  return a*b;
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Mimran</title>
		<link>http://www.learningprocessing.com/exercises/chapter-7/exercise-7-6/comment-page-1/#comment-9890</link>
		<dc:creator>Patrick Mimran</dc:creator>
		<pubDate>Fri, 12 Mar 2010 15:40:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1460#comment-9890</guid>
		<description>in the exercise 7-5 

this is what i have done , but i am sure there is a simpler way to condense  int total =  a * b ;
 int total2  =  c * d  ; in one line but i don not know how ?
Could you tell to me how 

Thanks

P Mimran

void multos ( int a , int b , int c , int d ) {
  int total =  a * b ;
 int total2  =  c * d  ;
  println ( total) ;
  println (total2 ) ; 
  
}


{
 multos ( 2 , 3 , 4 , 5 )

}</description>
		<content:encoded><![CDATA[<p>in the exercise 7-5 </p>
<p>this is what i have done , but i am sure there is a simpler way to condense  int total =  a * b ;<br />
 int total2  =  c * d  ; in one line but i don not know how ?<br />
Could you tell to me how </p>
<p>Thanks</p>
<p>P Mimran</p>
<p>void multos ( int a , int b , int c , int d ) {<br />
  int total =  a * b ;<br />
 int total2  =  c * d  ;<br />
  println ( total) ;<br />
  println (total2 ) ; </p>
<p>}</p>
<p>{<br />
 multos ( 2 , 3 , 4 , 5 )</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learningprocessing.com/exercises/chapter-7/exercise-7-6/comment-page-1/#comment-9889</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 12 Mar 2010 12:32:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1460#comment-9889</guid>
		<description>Of course, it totally makes sense :)
Thanks for your quick reply!</description>
		<content:encoded><![CDATA[<p>Of course, it totally makes sense <img src='http://www.learningprocessing.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Thanks for your quick reply!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Shiffman</title>
		<link>http://www.learningprocessing.com/exercises/chapter-7/exercise-7-6/comment-page-1/#comment-9872</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Thu, 11 Mar 2010 17:08:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1460#comment-9872</guid>
		<description>This is because there is only one variable &#039;x&#039; for all of the balls.  So x = x+speed gets called multiple times each cycle through draw().  Option one would be to have x1,x2,x3,etc. for all the balls, but a better option would be to use object-oriented programming and arrays (chapters 8 and 9).   Or if all the balls really just stay together always, you could say:

&lt;pre&gt;
void setup() {
  size(200,200);
  background(0);
  noStroke();
  fill(255);
  smooth();
  frameRate(30);
}

float x = 10;
float speed = 1;
float diam = 10;

void draw() {
  background(0);
  drawBall(30);
  drawBall(50);
  drawBall(70);
  drawBall(90);
  drawBall(110);
  drawBall(130);
  
  moveBall();
}

void drawBall(int yPos) {
  ellipse(x,yPos,diam,diam);
}

void moveBall(){
  if ((x &gt; width-(diam/2))) {
    speed = speed*(-1);
  }
  x = x+speed;
}

&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>This is because there is only one variable &#8216;x&#8217; for all of the balls.  So x = x+speed gets called multiple times each cycle through draw().  Option one would be to have x1,x2,x3,etc. for all the balls, but a better option would be to use object-oriented programming and arrays (chapters 8 and 9).   Or if all the balls really just stay together always, you could say:</p>
<pre>
void setup() {
  size(200,200);
  background(0);
  noStroke();
  fill(255);
  smooth();
  frameRate(30);
}

float x = 10;
float speed = 1;
float diam = 10;

void draw() {
  background(0);
  drawBall(30);
  drawBall(50);
  drawBall(70);
  drawBall(90);
  drawBall(110);
  drawBall(130);

  moveBall();
}

void drawBall(int yPos) {
  ellipse(x,yPos,diam,diam);
}

void moveBall(){
  if ((x > width-(diam/2))) {
    speed = speed*(-1);
  }
  x = x+speed;
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learningprocessing.com/exercises/chapter-7/exercise-7-6/comment-page-1/#comment-9845</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Wed, 10 Mar 2010 22:21:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1460#comment-9845</guid>
		<description>Hi,

I wrote the following code as an exercise, and 2 things seem weird to me:
- how come all the instances of the ball are not aligned vertically?
- why do the balls move slower if I remove some of them?

Thanks in advance for your help ;)

&lt;pre&gt;
void setup() {
  size(200,200);
  background(0);
  noStroke();
  fill(255);
  smooth();
  frameRate(30);
}

float x = 10;
float speed = 1;
float diam = 10;

void draw() {
  background(0);
  moveBall(30);
  moveBall(50);
  moveBall(70);
  moveBall(90);
  moveBall(110); //these balls are not aligned vertically.
  moveBall(130); //the more I add, the faster they move!
}

void moveBall(int yPos) {
  if ((x &gt; width-(diam/2))) {
    speed = speed*(-1);
  }
  x = x+speed;
  ellipse(x,yPos,diam,diam);
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I wrote the following code as an exercise, and 2 things seem weird to me:<br />
- how come all the instances of the ball are not aligned vertically?<br />
- why do the balls move slower if I remove some of them?</p>
<p>Thanks in advance for your help <img src='http://www.learningprocessing.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<pre>
void setup() {
  size(200,200);
  background(0);
  noStroke();
  fill(255);
  smooth();
  frameRate(30);
}

float x = 10;
float speed = 1;
float diam = 10;

void draw() {
  background(0);
  moveBall(30);
  moveBall(50);
  moveBall(70);
  moveBall(90);
  moveBall(110); //these balls are not aligned vertically.
  moveBall(130); //the more I add, the faster they move!
}

void moveBall(int yPos) {
  if ((x > width-(diam/2))) {
    speed = speed*(-1);
  }
  x = x+speed;
  ellipse(x,yPos,diam,diam);
}
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

