Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList<Cube> cubes;
- void setup() {
- size(500, 500, P3D);
- smooth(6);
- frameRate(30);
- cubes = new ArrayList();
- int cubeNum = 0;
- for (int i = 0; i < 10; i++) {
- for (int j = 0; j < 15; j++) {
- cubes.add(new Cube(50*i+25, 35*j+10, 35*j, cubeNum));
- cubeNum ++;
- }
- }
- for (int i = 0; i < cubes.size (); i++) {
- Cube c = (Cube) cubes.get(i);
- c.timeStampAnim = millis();
- c.timeStampDelay = millis();
- }
- }
- void draw() {
- background(25);
- // camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, mouseY, 0, 0, 1, 0);
- camera(width/2.0, height/2.0, 675, width/2.0, height/2, 0, 0, 1, 0);
- println(mouseX*3);
- for (int i = 0; i < cubes.size (); i++) {
- Cube c = (Cube) cubes.get(i);
- c.draw();
- }
- }
- class Cube {
- // timer interne de l'animation
- float timeStampAnim, intervalAnim;
- boolean beginTimerAnim;
- // timer pour activer le timer de l'animat selon le delai entré en param
- float timeStampDelay, intervalDelay;
- boolean animate;
- float posX, posY, angleY, posZ;
- int cubeNum;
- Cube(float posX, float posY, float posZ, float delay) {
- // timer interne de l'animation
- timeStampAnim = millis();
- intervalAnim = 5000; // chaque 5 secondes, l'animation joue (si elle doit le faire)
- beginTimerAnim = false;
- // timer pour activer le timer de l'animat selon le delai entré en param
- timeStampDelay = cubeNum * 100;
- intervalDelay = delay * 50;
- animate = false;
- this.posX = posX;
- this.posY = posY;
- this.posZ = posY;
- angleY = 45;
- // println(intervalDelay);
- }
- void draw() {
- pushMatrix();
- // posZ = mouseX;
- translate(posX, posY, posZ);
- //rotateX(radians(-45));
- rotateY(radians(angleY));
- stroke(25);
- strokeWeight(1.5);
- box(35);
- popMatrix();
- if (animate) {
- if (angleY < 135) {
- angleY+=5;
- } else { // >=
- animate = false;
- angleY = 45;
- }
- }
- if (beginTimerAnim) {
- if (millis() - timeStampAnim >= intervalAnim) {
- animate = true;
- timeStampAnim = timeStampAnim + intervalAnim;
- }
- }
- if (!beginTimerAnim) {
- if (millis() - timeStampDelay >= intervalDelay) {
- beginTimerAnim = true;
- timeStampAnim = millis();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement