INTERNET ART: networks, performative programming, and web as context

Flashing Pong

Leave a comment

//Pong stlye game changes

boolean gameStart = false;

float x = 150;
float y = 150;
float speedX = random(2, 6);
float speedY = random(2, 6);
int leftsideColor = 50;
int rightsideColor = 50;
int diam;
int rectSize = 150;
float diamHit;
void setup() {
size(500, 500);
noStroke();
smooth();
ellipseMode(CENTER);
}

void draw() {
background(255);

fill(120,200,120);
diam = 20;
ellipse(x, y, diam, diam);

fill(leftsideColor);
rect(0, 0, 20, height);
fill(rightsideColor);
rect(width-30, mouseY-rectSize/2, 10, rectSize);

//void WriteScoreAndTime(){
//fill(255);
//textSize(32);
//text(hits, width/6, height/6);
//}
if (gameStart) {

x = x + speedX;
y = y + speedY;

// if ball hits bouncable bar
if ( x > width-30 && x < width -20 && y > mouseY-rectSize/2 && y < mouseY+rectSize/2 ) {
speedX = speedX * -1;
x = x + speedX;
rightsideColor = 0;
fill(random(0,128),random(0,128),random(0,128));
diamHit = random(255,255);
ellipse(x,y,diamHit,diamHit);
rectSize = rectSize-10;
rectSize = constrain(rectSize, 10,150);
background(random(0,230),random(0,230),random(0,230));
//println(“Keep it going!”||”Don’t mess up!”||”Bouncy Balls!”);
}

// if ball hits wall
else if (x < 25) {
speedX = speedX * -1.1;
x = x + speedX;
leftsideColor = 0;
background(random(0,230),random(0,230),random(0,230));
//println(“Yeah! Get it!”||”Here we go!”||”Watch out!”);
}

else {
leftsideColor = 100;
rightsideColor = 100;
}
//if you lose
if (x > width) {
gameStart = false;
x = 150;
y = 150;
speedX = random(2, 6);
speedY = random(2, 6);
rectSize = 150;
background(255,0,0);
//println(“You lost your ball!!!”||”It’s really not okay…”||”My 12 month old did better, just saying…”);
}
// if ball hits bottom and top
if ( y > height || y < 0 ) {
speedY = speedY * -1;
y = y + speedY;
strokeWeight(2);
}
}
}
void mousePressed() {
gameStart = !gameStart;
}IMG_0699.JPG

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s