Monday, 11 June 2012

Singing bowl code..


//I'm using Eclipse with Android for Processing

package processing.test.bowl;

import processing.core.*; 

import edu.uic.ketai.inputService.*; 

import apwidgets.*; 


public class Bowl extends PApplet {


PMediaPlayer player;
KetaiSensorManager sensorManager;
PFont budd;
PImage stick, bowl;
int value = 0;
int cx = 250;
int cy = 250;
int r = 100;//radius of circular movement


public void setup()
{

  player = new PMediaPlayer(this); //create new PMediaPlayer
  player.setMediaFile("bowlHit.mp3"); //set the file (files are in data folder)
  budd = loadFont("OlympusBold-48.vlw");
  stick = loadImage("stick.png");
  bowl= loadImage("bowl.png");
  textFont(budd, 28);
  smooth();
}

public void draw()
{
 imageMode(CORNER);
  image(bowl, 0, 0, width, height);
  float angle = atan2(mouseY-cy, mouseX-cx);

  float x = cos(angle) * 220 + cx; //amount and width of rotation
  float y = sin(angle) * 220 + cy;
  imageMode(CENTER);
  fill(0);
  image(stick, x+120, y, stick.width/4, stick.height/4);
  fill(0, 255, 0);
  text("press & move the stick to play bowl", 40, height-100);
}



public void mousePressed() { 

  player.start(); //start play back

  player.setVolume(1.0f, 1.0f); //Set left
}


  public int sketchWidth() { return 500; }
  public int sketchHeight() { return 500; }
}

1 comment: