Advertisement
Guest User

Untitled

a guest
Nov 27th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1.  
  2. import processing.opengl.*;
  3. import java.awt.Color;
  4.  
  5. PFont font;
  6.  
  7. ArrayList cubes;
  8. int maxCubes = 10; // Max num of cubes
  9.  
  10.  
  11. void setup() {
  12. size(600, 600, OPENGL);
  13.  
  14. smooth();
  15.  
  16. //Load font for debug Info
  17. font = loadFont("LucidaGrande-12.vlw");
  18. textFont(font);
  19.  
  20.  
  21. //Create ArrayList of Cubes
  22. cubes = new ArrayList();
  23. for (int i = 0; i < maxCubes; i++) {
  24. cubes.add(new cube(int(random(100, 200)), int(random(100, 200)), 200));
  25. }
  26. }
  27. void draw() {
  28. background(90);
  29. lights();
  30. for (int i = cubes.size() - 1; i >= 0; i--) {
  31. cube Cube = (cube) cubes.get(i);
  32. Cube.run();
  33. }
  34. info();
  35. }
  36.  
  37. //Debug Info
  38. void info() {
  39. text("Frame", 10, 20);
  40. text(frameCount, 60, 20);
  41. text("FPS", 10, 40);
  42. text(round(frameRate), 60, 40);
  43. }
  44.  
  45. class cube{
  46.  
  47. int xSpin; //Amount of rotation on Y
  48. int ySpin; //Amount of rotation on Y
  49. int dim; //Dimension (width)
  50.  
  51. cube(int _xSpin, int _ySpin, int _dim){
  52.  
  53. xSpin = _xSpin;
  54. ySpin = _ySpin;
  55. dim = _dim;
  56.  
  57. }
  58.  
  59. void run(){
  60. pushMatrix();
  61. translate(width/2, height/2);
  62. noStroke();
  63. fill(255);
  64. rotateX(PI*frameCount/xSpin);
  65. rotateY(PI*frameCount/ySpin);
  66. box(dim);
  67. popMatrix();
  68. }
  69. }
  70.  
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement