topical media & game development

talk show tell print

graphic-processing-algorithm-Ch08-p195-MyObject.pde / pde



  class MyObject{
    float dim = 40; //size of the object
    float x,y,z; //position coordinates
    boolean picked = false; //picked status
    color c_face = color(255); //color of object//determine whether an object is picked
    void pick(float xp, float yp){
      //is the distance enough to pick?
      if(dist(xp,yp,screenX(x,y,z),screenY(x,y,z))<dim)
        picked = true;
      else
        picked = false;
    }
    void draw3(){
      if(picked==true)
        fill(255,0,0); //paint red to indicate picked
      else
        fill(c_face); //normal color
      box(dim);
    }
  }
  


(C) Æliens 04/09/2009

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.