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

Shutter Game Code (So Far)

Leave a comment

//for this code everytime you click the mouse
//a camera shutter will close and a new image will appear as the background
// if you capture a person in frame you score a point
// as the game progresses (10 levels) the camera lens turns into a sniper scope
// by the final image you have to shoot the charcter with the cross hairs lining up on their body
//win by scoring 10/10.

//PImage[] images = new PImage[9];
PImage USA;
PImage UK;
PImage Rus;
PImage Mex;
PImage Tah;
PImage Chi;
PImage Ger;
PImage Fra;
PImage Jap;
PImage War;
PImage Man;
int imageVariable = 0;
float x = 200;
float y = 200;
float moveX = 5;
float moveY = 5;
boolean collision = false;
int hit = 0;
float shutter = 50; //shutter speed
float r = 700; // shutter size
float w = 70;
float h = 70;

void setup(){

USA = loadImage (“0.jpg”);
UK = loadImage (“1.jpg”);
Rus = loadImage (“2.jpg”);
Mex = loadImage (“3.jpg”);
Tah = loadImage (“4.jpg”);
Chi = loadImage (“5.jpg”);
Ger = loadImage (“6.jpg”);
Fra = loadImage (“7.jpg”);
Jap = loadImage (“8.jpg”);
War = loadImage (“9.jpg”);
Man = loadImage (“Man.jpg”);
size(1500,900);

}

void draw(){
reset();
Imagechange();
crosshairs(mouseX,mouseY);
hit();
score();
Shutter();
Character();

}

void Shutter(){

fill(255,255,255,1); //opacity of lens
ellipse(mouseX,mouseY,r,r);//shutter

if (mousePressed){ //while mouse pressed the ellipse will shrink really fast and reset like a camera shutter
r = r – shutter;
}
if (r <= 0){
r = 900;
}
}

void mouseClicked(){
imageVariable = imageVariable +1;
Character();
}
void blackbackground(){

//PGraphics circle;

//void setup() {
// size(100, 100);
// circle = createGraphics(100, 100);
//}

//void draw() {
// circle.beginDraw();
// circle.background(0);
// circle.ellipse(50, 50, 75, 75);
// circle.endDraw();
// image(circle, 0, 0);
//}

}

void Imagechange() {

if (imageVariable ==1){
image(USA,0,0);
}
else if (imageVariable ==2){
image(UK, 0,0);
}
else if (imageVariable ==3){
image(Rus,0,0);
}
else if (imageVariable ==4){
image(Mex,0,0);
}
else if (imageVariable ==5){
image(Tah,0,0);
}
else if (imageVariable ==6){
image(Ger,0,0);
}
else if (imageVariable ==7){
image(Fra,0,0);
}
else if (imageVariable ==8){
image(Jap,0,0);
}
else if (imageVariable ==9){
image(Chi,0,0);
}
else if (imageVariable ==10){
image(War,0,0);
}

}
void crosshairs(float a, float b) {

if (imageVariable >= 5){
fill(0,255,0,30);
line(mouseX,mouseY-100,mouseX,mouseY+100);
line(mouseX-100, mouseY, mouseX+100, mouseY);
}

}

void Character() {
// noStroke();
rect(x,y,w,h);
image(Man,x,y);
x = x + moveX;
y = y + moveY;

if(y > 900){
moveY = -moveY;
}
if(y < 0){
moveY = -moveY;
}
if(x > 1500){
moveX = -moveX;
}
if (x < 0){
moveX = -moveX;
}

}

void hit(){

if (mouseX ==x && mouseY == y){

collision = true;
println(“Gotcha!”);
hit = hit+1;
}

else {
collision = false;
}

}
void score(){

fill(0);
stroke(0);
textSize(20);
text(“The Shutter Game”, width/2, height/10);
text(hit, width/6, height/10);
text((millis()/1000), width-200,height/10);

}

void reset(){
if (imageVariable>10){
background(0);
textSize(70);
fill(255);
text(“Click to Restart”, width/3, height/2);
imageVariable=0;
}
}

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