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

code

Leave a comment

int ballX = 250;
int ballY = 250;

int xSpeed = -1;
int ySpeed = 2;

int playerOneX = 0;
int playerOneY = 250;

int playerTwoX = 475;
int playerTwoY = 250;

int paddleHeight = 90;
int paddleWidth = 25;

int playerOneScore = 0;
int playerTwoScore = 0;

void setup() {
size(500, 500);

}

void draw() {
background(225);
noStroke();

if (keyPressed) {
if (keyCode == UP) {
if (playerOneY > 0) {
playerOneY = playerOneY – 5;
}
}

if (keyCode == DOWN) {
if (playerOneY + paddleHeight < 500) {
playerOneY = playerOneY + 5;
}
}
}

if (playerTwoY < mouseY) {
playerTwoY = playerTwoY + 5;
}

if (playerTwoY > mouseY) {
playerTwoY = playerTwoY – 5;
}

ballX = ballX + xSpeed;
ballY = ballY + ySpeed;

if (ballY < 0) {
ySpeed = ySpeed * -1;
}

if (ballY > 500) {
ySpeed = ySpeed * -1;
}

if (ballX < playerOneX + paddleWidth) {

if (ballY < playerOneY) {
playerTwoScore = playerTwoScore + 1;
ballX = 250;
ballY = 250;
}

if (ballY > playerOneY + paddleHeight) {
playerTwoScore = playerTwoScore + 1;
ballX = 250;
ballY = 250;
}

xSpeed = xSpeed * -1;
}

if (ballX > playerTwoX) {

if (ballY < playerTwoY) {
playerOneScore = playerOneScore + 1;
ballX = 250;
ballY = 250;
}

if (ballY > playerTwoY + paddleHeight) {
playerOneScore = playerOneScore + 1;
ballX = 250;
ballY = 250;
}

xSpeed = xSpeed * -1;
}

fill( 50, 55, 100);
textSize(70);
text(playerOneScore, 100, 100);
text(playerTwoScore, 350, 100);
rect(playerOneX, playerOneY, paddleWidth, paddleHeight);
fill ( 50, 100, 150);
rect(playerTwoX, playerTwoY, paddleWidth, paddleHeight);
fill ( 255, 204, 0);
ellipse(ballX, ballY, 70, 70);
ellipseMode(RADIUS);

}

Author: Catalina Caban

Art Director

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