/** ********************	
    Name:
    Date:
    Class:
    Note: Fill in the appropriate sections to make your program.
 */

// Quick comment.

/** Longer comment */

/** ********************
  Variables:
    Variables provide a way to save information within your sketch 
    and use it to control size, position, shape, etc. of what
    you are drawing.
 */

// Numbers for just one of the helicopters
float xPos_1 = 0;    // x position to draw the image
float yPos_1 = 0;    // y position to draw the image
float ro_1 = 0;    // rotation angle of the image
float si_1 = 1.0;    // size of the image as a percent, so 1.0 means 100%

// Used by all of the helicopters
int imageNumber = 0;     // which version of the image to draw

// This is the state variable
int state = 0;

// These are my Font variables
PFont bigFont;
PFont mediumFont;
PFont littleFont;

/** ********************
  setup():
    Use setup() to specify things that need to be done once, 
    when the sketch first opens.
 */
void setup() {
  background(#ffffff);
  frameRate(20);
  size(800,600);
  
  // Before you can create text you need to create a font (in this case I create 3).
  // Rather then create my own font from scratch, I ask for a list of what fonts are already available on this machine.
  String[] fontList = PFont.list();   
  // I will use the first available font, to create my three custom fonts, each with a diffrent size.  
  bigFont = createFont(fontList[0], 32);     // A big size font for the title
  mediumFont = createFont(fontList[0], 20);  // A medium size font.
  littleFont = createFont(fontList[0], 14);  // A little size font.
  
  
}

/** ********************
  draw():  
    Use draw() to specify things that you want to have done repeatedly.
    draw() must be present in your program, even if it is left empty.
 */
void draw() {
  background(#ffffff);
  
  if(state == 0) {
    
      start_screen();      // call the start_screen() funtion.
    
  } else { 
      
      // Draw the image at 0,0 not rotated or scaled.
      simpleAnimatedImage(0.0, 0.0, 0.0, 1.0, 0);
      
      // Draw the image using the variables.
      simpleAnimatedImage(xPos_1, yPos_1, ro_1, si_1, imageNumber);
      // Change the variables
      if(xPos_1 < width) {
        xPos_1++;             // x position to draw the image
        yPos_1++;             // y position to draw the image
        ro_1++;               // rotation angle of the image
        si_1 = si_1 + 0.01;    // size of the image
      } else {
        xPos_1 = 0;    
        yPos_1 = 0;    
        ro_1 = 0;    
        si_1 = 1.0;    
      }
      
      // Draw the image on the mouse
      simpleAnimatedImage(mouseX, mouseY, 0, 1.0, imageNumber);  
      
  }
  
  if( imageNumber ==  0) {
    imageNumber = imageNumber + 1;
  } else if(imageNumber == 1) {
    imageNumber = 0;
  }

  
}

/** ********************
  Event Handlers:
    Use event-handlers like keyPressed() to allow users of your program 
    to cause things to happen.
 */
void mouseClicked() {

    state = 1;
    
}

/** ********************
  Custom Functions:
    Use this section for functions that you create and name.
 */

void simpleAnimatedImage(float x, float y, float r, float s, int i) {
  pushMatrix();     // Save the state of the world
  translate(x,y);    // Move the world in order to move what is drawn
  rotate( radians(r) );   // Change angle of the world to change angle of image drawn
  scale(s);  // Change the size of the object (by a percent, example 2.0 would be 200%)

  if(i == 0) {
      // draw first image
      
      stroke(#000000);
      fill(#000000);
      quad( 0,-10, 55,10, 55,0, -35,20);
      line(0,-10, 40,-20);    
      
  } else if(i == 1) {
      // draw second image

      stroke(#000000);
      fill(#000000);    
      quad( 0,-10, 55,10, 55,0, -35,20);
      line(0,-10, -40,0);   
      
  }
        
  popMatrix();    // Reset the world
}

void start_screen() {

  // These four lines create the title.
  textFont(bigFont);
  textAlign(CENTER);
  fill(#000000);
  text("Simple Processing Animation", width/2, 100);   
  
}

/** ********************
  Classes:
    Used to create objects.
 */

      

Source code: TemplateProgram2

Built with Processing