Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import processing.opengl.*;
- import java.awt.Color;
- PFont font;
- ArrayList cubes;
- int maxCubes = 10; // Max num of cubes
- void setup() {
- size(600, 600, OPENGL);
- smooth();
- //Load font for debug Info
- font = loadFont("LucidaGrande-12.vlw");
- textFont(font);
- //Create ArrayList of Cubes
- cubes = new ArrayList();
- for (int i = 0; i < maxCubes; i++) {
- cubes.add(new cube(int(random(100, 200)), int(random(100, 200)), 200));
- }
- }
- void draw() {
- background(90);
- lights();
- for (int i = cubes.size() - 1; i >= 0; i--) {
- cube Cube = (cube) cubes.get(i);
- Cube.run();
- }
- info();
- }
- //Debug Info
- void info() {
- text("Frame", 10, 20);
- text(frameCount, 60, 20);
- text("FPS", 10, 40);
- text(round(frameRate), 60, 40);
- }
- class cube{
- int xSpin; //Amount of rotation on Y
- int ySpin; //Amount of rotation on Y
- int dim; //Dimension (width)
- cube(int _xSpin, int _ySpin, int _dim){
- xSpin = _xSpin;
- ySpin = _ySpin;
- dim = _dim;
- }
- void run(){
- pushMatrix();
- translate(width/2, height/2);
- noStroke();
- fill(255);
- rotateX(PI*frameCount/xSpin);
- rotateY(PI*frameCount/ySpin);
- box(dim);
- popMatrix();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement