Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- color bg = #C38018;
- color s = #662121;
- color f = #330404;
- ArrayList bricks = new ArrayList();
- void setup() {
- size(500, 500);
- background(bg);
- stroke(s,150);
- strokeWeight(2);
- fill(f);
- rectMode(CENTER);
- int y = 0;
- int h = 2;
- float w = 200;
- float theta = 0;
- while (y<height+50) {
- y += h;
- Brick brick = new Brick(y, h, theta);
- bricks.add(brick);
- h += 2;
- theta += TAU/25;
- }
- }
- void draw() {
- background(bg);
- for (int i=0; i<bricks.size();i++) {
- Brick brick = (Brick) bricks.get(i);
- brick.run();
- }
- if (frameCount % 2 == 0 && frameCount<121) saveFrame("image-####.gif");
- }
- class Brick {
- float y, h, w, theta;
- Brick(float _y, float _h, float _theta) {
- y = _y;
- h = _h;
- theta = _theta;
- }
- void run() {
- move();
- display();
- }
- void move() {
- w = map(sin(theta*2), -1, 1, .8, 1.5);
- theta += 0.0523;
- }
- void display() {
- rect(width/2, y-h/2, (300-5*h)*w, h);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement