<?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: Example 4-7: Filling Variables with Random Values</title>
	<atom:link href="http://www.learningprocessing.com/examples/chapter-4/example-4-7/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: Jonathan Dryhurst Roberts</title>
		<link>http://www.learningprocessing.com/examples/chapter-4/example-4-7/comment-page-1/#comment-16238</link>
		<dc:creator>Jonathan Dryhurst Roberts</dc:creator>
		<pubDate>Sun, 12 Dec 2010 15:20:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=334#comment-16238</guid>
		<description>Patrick: variables x, and X are not the same.</description>
		<content:encoded><![CDATA[<p>Patrick: variables x, and X are not the same.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Mimran</title>
		<link>http://www.learningprocessing.com/examples/chapter-4/example-4-7/comment-page-1/#comment-16237</link>
		<dc:creator>Patrick Mimran</dc:creator>
		<pubDate>Sun, 12 Dec 2010 15:18:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=334#comment-16237</guid>
		<description>I do not understand why i am obliged to declare two times the same variables x=0 X=0 y=0 Y1=0
to make this work . If i only declare two variables and use them in all the ifs  it does not work .
i do not understand why , could you give to me a little explanation

Thanks

Patrick


  int x = 0 ;
int y = 0 ;
int X = 0 ;
int Y1 = 0 ;
int H = 30 ;
int speed = 5 ;

int state = 0 ;

void setup() {
  size (500, 500);
  smooth();
}

void draw()

{
  
  background(204);
 
  fill ( 250 , 0 , 0 );

   
  ellipse(x , y + 250  , 30 ,30 ) ;
   x = x + speed ;
  if ( x &gt; width+30) {
   state = 1 ;
  }
  if  (state == 1 ) {
    fill ( 200 , 30 , 89 );
    ellipse (width/2 ,y , 30 ,30 ) ;
    y = y + speed ; 
    
    if ( y &gt; height+30 ) {
    state = 2 ;
    }
 
     if ( state == 2 ) {
       
    ellipse ( X , height/2 , 30 ,H ) ;
    H += 3 ;
    X = X + speed ;
    if ( X &gt; width + 30 )
   state = 3 ;
   
     }
   
   if ( state == 3 ) {
      fill ( 50 , 150 , 200 );
    ellipse (width/2 ,Y1 , 90 ,H ) ;
    H += 1 ;
    Y1 = Y1 + speed ; 
    state = 4 ;
     
     
   
   
     } }}</description>
		<content:encoded><![CDATA[<p>I do not understand why i am obliged to declare two times the same variables x=0 X=0 y=0 Y1=0<br />
to make this work . If i only declare two variables and use them in all the ifs  it does not work .<br />
i do not understand why , could you give to me a little explanation</p>
<p>Thanks</p>
<p>Patrick</p>
<p>  int x = 0 ;<br />
int y = 0 ;<br />
int X = 0 ;<br />
int Y1 = 0 ;<br />
int H = 30 ;<br />
int speed = 5 ;</p>
<p>int state = 0 ;</p>
<p>void setup() {<br />
  size (500, 500);<br />
  smooth();<br />
}</p>
<p>void draw()</p>
<p>{</p>
<p>  background(204);</p>
<p>  fill ( 250 , 0 , 0 );</p>
<p>  ellipse(x , y + 250  , 30 ,30 ) ;<br />
   x = x + speed ;<br />
  if ( x &gt; width+30) {<br />
   state = 1 ;<br />
  }<br />
  if  (state == 1 ) {<br />
    fill ( 200 , 30 , 89 );<br />
    ellipse (width/2 ,y , 30 ,30 ) ;<br />
    y = y + speed ; </p>
<p>    if ( y &gt; height+30 ) {<br />
    state = 2 ;<br />
    }</p>
<p>     if ( state == 2 ) {</p>
<p>    ellipse ( X , height/2 , 30 ,H ) ;<br />
    H += 3 ;<br />
    X = X + speed ;<br />
    if ( X &gt; width + 30 )<br />
   state = 3 ;</p>
<p>     }</p>
<p>   if ( state == 3 ) {<br />
      fill ( 50 , 150 , 200 );<br />
    ellipse (width/2 ,Y1 , 90 ,H ) ;<br />
    H += 1 ;<br />
    Y1 = Y1 + speed ;<br />
    state = 4 ;</p>
<p>     } }}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Shiffman</title>
		<link>http://www.learningprocessing.com/examples/chapter-4/example-4-7/comment-page-1/#comment-8115</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Mon, 04 Jan 2010 19:52:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=334#comment-8115</guid>
		<description>Thanks for the suggestion. Although color values (as well as pixel values) are truly integers at heart, Processing allows you to use floats with all of its functions for convenience.  So I find that it&#039;s actually often more confusing to have to write the extra code:

int r;

r = int(random(255));

But this is an important point that I should be aware of, thank you!!</description>
		<content:encoded><![CDATA[<p>Thanks for the suggestion. Although color values (as well as pixel values) are truly integers at heart, Processing allows you to use floats with all of its functions for convenience.  So I find that it&#8217;s actually often more confusing to have to write the extra code:</p>
<p>int r;</p>
<p>r = int(random(255));</p>
<p>But this is an important point that I should be aware of, thank you!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: haptiK</title>
		<link>http://www.learningprocessing.com/examples/chapter-4/example-4-7/comment-page-1/#comment-7971</link>
		<dc:creator>haptiK</dc:creator>
		<pubDate>Sat, 26 Dec 2009 19:15:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/wp/?page_id=334#comment-7971</guid>
		<description>When discussing the usage of the random() function in your book, you explained the need to sometimes change the value received from random() into an integer using int() or casting it as (int).

Granted it is not necessary to always do this, but I think it would have been much wiser to do it in this example considering RGB values should really not be floats and doing so would have added a level of consistency.</description>
		<content:encoded><![CDATA[<p>When discussing the usage of the random() function in your book, you explained the need to sometimes change the value received from random() into an integer using int() or casting it as (int).</p>
<p>Granted it is not necessary to always do this, but I think it would have been much wiser to do it in this example considering RGB values should really not be floats and doing so would have added a level of consistency.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

