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

Lionel RIchie Game Code

Leave a comment

import ddf.minim.*;
Minim minim;
AudioPlayer player;
AudioPlayer player2;
int gameScreen = 0;
int ballX, ballY;
int ballSize = 50;
int ballColor = color(0);
float gravity = 5;
float ballSpeedVert = 0;
int hits = 0;
PImage img;

void setup() {
size(500, 500);
ballX=width/4;
ballY=height/5;
minim = new Minim(this);
player = minim.loadFile (“fiesta.mp3”);
player2 = minim.loadFile (“party.mp3”);
img = loadImage(“Lionel2.jpg”);

}
void draw() {
if (gameScreen == 0) {
initScreen();
} else if (gameScreen == 1) {
gameScreen();
} else if (gameScreen == 2){
hits = 2;
gameOverScreen();
}
WriteScoreAndTime();
}
public void keyPressed() {

if (gameScreen==0) {
startGame();
}
}
void mouseClicked(){
if (ballY == height/2){
hits = hits+1;
}
if (hits == 6){
gameScreen =2;
}
}
void startGame(){
gameScreen=1;
}
void initScreen() {
background(0);
textAlign(CENTER);
text(“press any key”, height/2, width/2);
player.loop();
}

void gameScreen() {
background(img);
drawBall();
applyGravity();
keepInScreen();
virtue();
WriteScoreAndTime();
player2.loop();
}
void drawBall() {
fill(ballColor);
ellipse(ballX, ballY, ballSize, ballSize);
}
void virtue(){
rect(height/2, width/2, 500, 10);

}
void applyGravity(){
ballSpeedVert += gravity;
ballY += ballSpeedVert;
}
void makeBounceBottom(int surface) {
ballY = surface-(ballSize/2);
ballSpeedVert*=-1;
}

void makeBounceTop(int surface) {
ballY = surface+(ballSize/2);
ballSpeedVert*=-1;
}

void keepInScreen() {

if (ballY+(ballSize/2) > height) {
makeBounceBottom(height);
}

if (ballY-(ballSize/2) < 0) {
makeBounceTop(0);
}
}

void gameOverScreen() {
background(0);
textAlign(CENTER);
fill(255);
text(“GME OVR”, height/2, width/2);
player2.loop();

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

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