remigroot / Design-by-Code

Design by code is a course aimed at the basic understanding of the programming language of Processing.
0 stars 0 forks source link

poster music #2

Open remigroot opened 10 years ago

remigroot commented 10 years ago

int ballRadius = 15; float ballXSpeed = 2; float ballYSpeed = 2;

int ballPosX; int ballPosY;

int ballRadius2 = 6; float ballXSpeed2 = 2; float ballYSpeed2 = 2;

int ballPosX2; int ballPosY2;

int ballRadius3 = 14; float ballXSpeed3 = 2; float ballYSpeed3 = 2;

int ballPosX3; int ballPosY3;

int ballRadius4 = 7; float ballXSpeed4 = 2; float ballYSpeed4 = 2;

int ballPosX4; int ballPosY4;

int ballRadius5 = 14; float ballXSpeed5 = 2; float ballYSpeed5 = 2;

int ballPosX5; int ballPosY5;

int ballRadius6 = 9; float ballXSpeed6 = 2; float ballYSpeed6 = 2;

int ballPosX6; int ballPosY6;

int ballRadius7 = 18; float ballXSpeed7 = 2; float ballYSpeed7 = 2;

int ballPosX7; int ballPosY7;

int ballRadius8 = 16; float ballXSpeed8 = 2; float ballYSpeed8 = 2;

int ballPosX8; int ballPosY8;

int ballRadius9 = 18; float ballXSpeed9 = -2; float ballYSpeed9 = -1.9;

int ballPosX9; int ballPosY9;

int ballRadius10 = 10; float ballXSpeed10 = -2; float ballYSpeed10 = -1.9;

int ballPosX10; int ballPosY10;

PFont font; int ypos; int xpos; float opa; // float is any number with decimal places like: 2.234782634 int inc; // will be used to moving shapes and text allong color col; boolean el; //boplean value is used as switch to run once

void setup() { frameRate(120); size(500,500); background(0);

ballPosX = 520; ballPosY = width/2-4; ballPosX2 = 520; ballPosY2 = width/2+10; ballPosX3 = 520; ballPosY3 = width/2+18; ballPosX4 = 520; ballPosY4 = width/2+24; ballPosX5 = 520; ballPosY5 = width/2+29; ballPosX6 = 520; ballPosY6 = width/2+35; ballPosX7 = 520; ballPosY7 = width/2+43; ballPosX8 = 520; ballPosY8 = height/2+50;

col = color(255); font = loadFont("Arual-48.vlw"); textFont(font); smooth(); textSize(70); ypos=270;
el = false; // starting value boolean = false }

void draw() {

fill(#5d6e9a); throwTheBall(); fill(#b7291b); throwTheBall2(); fill(#5d6e9a); throwTheBall3(); fill(#d89927); throwTheBall4(); fill(#35cc6f); throwTheBall5(); fill(#f8a40e); throwTheBall6(); fill(#b7291b); throwTheBall7(); fill(#d89927); throwTheBall8(); fill(#b7291b); throwTheBall9(); fill(#5d6e9a); throwTheBall10(); drawText(); }

void throwTheBall() { if(ballPosX > 520 || ballPosX < -20) { ballXSpeed = -ballXSpeed; }

if(ballPosY > 520 || ballPosY < -20) {
  ballYSpeed = -ballYSpeed;
}

ballPosX += ballXSpeed;
ballPosY += ballYSpeed;

ellipse(ballPosX, ballPosY, ballRadius, ballRadius);

}

void throwTheBall2() { if(ballPosX2 > 520 || ballPosX2 < -20) { ballXSpeed2 = -ballXSpeed2; }

if(ballPosY2 > 520 || ballPosY2 < -20) {
  ballYSpeed2 = -ballYSpeed2;
}

ballPosX2 += ballXSpeed2;
ballPosY2 += ballYSpeed2;

ellipse(ballPosX2, ballPosY2, ballRadius2, ballRadius2);

}

void throwTheBall3() { if(ballPosX3 > 520 || ballPosX3 < -20) { ballXSpeed3 = -ballXSpeed3; }

if(ballPosY3 > 520 || ballPosY3 < -20) {
  ballYSpeed3 = -ballYSpeed3;
}

ballPosX3 += ballXSpeed3;
ballPosY3 += ballYSpeed3;

ellipse(ballPosX3, ballPosY3, ballRadius3, ballRadius3);

}

void throwTheBall4() { if(ballPosX4 > 520 || ballPosX4 < -20) { ballXSpeed4 = -ballXSpeed4; }

if(ballPosY4 > 520 || ballPosY4 < -20) {
  ballYSpeed4 = -ballYSpeed4;
}

ballPosX4 += ballXSpeed4;
ballPosY4 += ballYSpeed4;

ellipse(ballPosX4, ballPosY4, ballRadius4, ballRadius4);

}

void throwTheBall5() { if(ballPosX5 > 520 || ballPosX5 < -20) { ballXSpeed5 = -ballXSpeed5; }

if(ballPosY5 > 520 || ballPosY5 < -20) {
  ballYSpeed5 = -ballYSpeed5;
}

ballPosX5 += ballXSpeed5;
ballPosY5 += ballYSpeed5;

ellipse(ballPosX5, ballPosY5, ballRadius5, ballRadius5);

}

void throwTheBall6() { if(ballPosX6 > 520 || ballPosX6 < -20) { ballXSpeed6 = -ballXSpeed6; }

if(ballPosY6 > 520 || ballPosY6 < -20) {
  ballYSpeed6 = -ballYSpeed6;
}

ballPosX6 += ballXSpeed6;
ballPosY6 += ballYSpeed6;

ellipse(ballPosX6, ballPosY6, ballRadius6, ballRadius6);

}

void throwTheBall7() {

if(ballPosX7 > 520 || ballPosX7 < -20) {
  ballXSpeed7 = -ballXSpeed7;
}

if(ballPosY7 > 520 || ballPosY7 < -20) {
  ballYSpeed7 = -ballYSpeed7;
}
ballPosX7 += ballXSpeed7;
ballPosY7 += ballYSpeed7;

ellipse(ballPosX7, ballPosY7, ballRadius7, ballRadius7);

}

void throwTheBall8() {

if(ballPosX8 > 520 || ballPosX8 < -20) {
  ballXSpeed8 = -ballXSpeed8;
}

if(ballPosY8 > 520 || ballPosY8 < -20) {
  ballYSpeed8 = -ballYSpeed8;
}
ballPosX8 += ballXSpeed8;
ballPosY8 += ballYSpeed8;

ellipse(ballPosX8, ballPosY8, ballRadius8, ballRadius8);

}

void throwTheBall9() {

if(ballPosX9 > 520 || ballPosX9 < -20) {
  ballXSpeed9 = -ballXSpeed9;
}

if(ballPosY9 > 520 || ballPosY9 < -20) {
  ballYSpeed9 = ballYSpeed9=0;
}
ballPosX9 += ballXSpeed9;
ballPosY9 += ballYSpeed9;

ellipse(ballPosX9, ballPosY9, ballRadius9, ballRadius9);

}

void throwTheBall10() {

if(ballPosX10 > 520 || ballPosX10 < -20) {
  ballXSpeed10 = -ballXSpeed;
}

if(ballPosY10 > 520 || ballPosY10 < -20) {
  ballYSpeed10 = ballYSpeed10=0;
}
ballPosX10 += ballXSpeed10;
ballPosY10 += ballYSpeed10;

ellipse(ballPosX10, ballPosY10, ballRadius10, ballRadius10);

}

void drawText(){ inc++; // add one to inc xpos=40;

opa=mouseY*2.5; if(mousePressed){ inc = 0; el = true;

} if(inc>1000){ inc = 1000; // set to a constant stroke(20); //white

} else{ fill(127,80);

}

fill(255); text("E", 2_xpos, ypos); text("l", 3_xpos, ypos); text("i", 3.6*xpos, ypos);

text("E", 4.5_xpos, ypos); text("s", 5.4_xpos, ypos); text("c", 6.2_xpos, ypos); text("o", 7.3_xpos, ypos); text("b", 8.6_xpos, ypos); text("a", 9.8_xpos, ypos); text("r", 11*xpos, ypos); strokeWeight(1.5);

}