topical media & game development

talk show tell print

graphic-processing-algorithm-Ch03-p70-MyShape.pde / pde



  class MyShape {
  MySegment[] segs; // members of class
  int numSegments;
  // Constructor
  MyShape(int numInputSegments, MySegment[] inputSegments){
  numSegments = numInputSegments;
  segs = new MySegment[numSegments];
  for(int i=0; i<numSegments; i++)
  segs[i] = inputSegments[i];
  }
  // Move
  void move(float xoff, float yoff){
  for(int i=0; i<numSegments; i++)
  segs[i].move(xoff, yoff);
  }
  // plot (or draw)
  void plot(){
  for(int i=0; i<numSegments; i++)
  segs[i].plot();
  }
  }
  


(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.