Saturday, March 10, 2012

super tiles!

float Radius = 20;
float positionBallX = random(width);
float positionBallY = Radius;         // ball position
float ballSpeedX = 10, ballSpeedY = 10; // velocity
color ballColor = color(random(0, 255), random(0, 255), random(0, 255));

void setup() {
  smooth();
  noStroke();
  size(800, 400);
  background(255);
}

void draw() {
  if (frameCount == 25) noLoop();
  for (int i = 0; i< 100; i++) {
    ballColor = color(positionBallX/3, random(0, 255), random(0, 255));

    positionBallX = positionBallX + ballSpeedX;
    positionBallY = positionBallY + ballSpeedY; 

    if (positionBallX > width-Radius || positionBallX < 0) {
      ballSpeedX = ballSpeedX * -1;
    } 

    if (positionBallY > height-2* Radius && ballSpeedY > 0 || positionBallY < 0) {
      ballSpeedY = ballSpeedY * -1;
    } 

    //stroke(0);
    fill(ballColor);
    rect(positionBallX, positionBallY, Radius*2, Radius*2);
    stroke(250, 250, 250);
  }
}

void mousePressed(){
  fill(255);
  rect(0,0,width,height);
  frameCount = 0;
  loop();
}

info info

submitted by: DARYL_Gamma
views: 33
just copied the animated bounce sketch and made it quicker. Click it to make another patch.

treeThis sketch has a parent
Tags:

comments comment

loading loading...

 

Add a comment: