Recap – Step By Step 15th November 2012

This is a recap app.. Shows variables and the IF statement working. Lets go through it and see whats going on when the code is running

// Variables

int count=0;
int p1x=50;
int p1y=50;
int lenx=450;
int leny=450;

void setup()
{

    size(500,500);
    count=0;
}
void draw()

{
  
    println("Hello I am in draw again this many times!!! " + count);
  
    count = count + 1;
    
    if (count > 500 )
    {
        count = 0;
  
    }    

    if (count > 0 && count < 100 ) 
    {
       fill(255,0,0);
       rect(p1x,p1y,lenx,leny); 
    }
  
    if (count > 100 && count < 200 ) 
    {
       fill(0,255,0);
       rect(p1x,p1y,lenx,leny); 
    }
  
    if (count > 200 && count < 300 ) 
    {
       fill(0,0,255);
        rect(p1x,p1y,lenx,leny);
    }
   if (count > 300 && count < 400 ) 
    {
       fill(255,255,255);
        rect(p1x,p1y,lenx,leny);
    }
   if (count > 400 && count < 500 ) 
    {
       fill(0,0,0);
        rect(p1x,p1y,lenx,leny);
    }
  
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s