topical media & game development

talk show tell print

graphic-processing-learning-20-example-20-3-example-20-3.pde / pde



  // Learning Processing
  // Daniel Shiffman
  // http://www.learningprocessing.com
  
  // Example 20-3: Doorbell with Minim
  
  import ddf.minim.*;
  
  // A doorbell object (that will trigger the sound)
  Doorbell doorbell;
  
  void setup() {
    size(200,200);
    // start up Minim
    Minim.start(this);
    
    // Create a new doorbell
    doorbell = new Doorbell(150,100,32, "dingdong.wav");
    smooth();
  }
  
  void draw() {
    background(100,100,126);
    
    // Show the doorbell
    doorbell.display(mouseX,mouseY);
    doorbell.jiggle();
  }
  
  void mousePressed() {
    
    // If the user clicks on the doorbell, play the sound!
    if (doorbell.contains(mouseX,mouseY)) {
      doorbell.ring();
    }
  }
  
  // Close the sound files
  public void stop() {
    // The doorbell object must close its sound.
    doorbell.close(); 
    super.stop();
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.