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

Election Day – Game Code

Leave a comment

This code has been updated since our critique. I added collisions and changed some of the graphics.

PImage You;
PImage pic2;
PImage pic3;
PImage pic4;
float YouY = -20;
float YouX = 0;
float width = 1270;
float height = 675;

float randX = random(1100, 3500);
float randX2 = random(1100, 3500);
float randX3 = random(1100, 3500);
float randX4 = random(1100, 3500);
float randX5 = random(1100, 3500);
float randX6 = random(1100, 3500);
float randX7 = random(1100, 3500);
float randX8 = random(1100, 3500);
float randX9 = random(1100, 3500);
float randX10 = random(1100, 3500);
float randX11 = random(1100, 3500);
float randX12 = random(1100, 3500);
float randX13 = random(1100, 3500);
float randX14 = random(1100, 3500);
float randX15 = random(1100, 3500);
float randX16 = random(1100, 3500);
float randX17 = random(1100, 3500);
float randX18 = random(1100, 3500);
float randX19 = random(1100, 3500);
float randX20 = random(1100, 3500);
float randX21 = random(1100, 3500);
float randX22 = random(1100, 3500);

float randY = random(675);
float randY2 = random(675);
float randY3 = random(675);
float randY4 = random(675);
float randY5 = random(675);
float randY6 = random(675);
float randY7 = random(675);
float randY8 = random(675);
float randY9 = random(675);
float randY10 = random(675);
float randY11 = random(675);
float randY12 = random(675);
float randY13 = random(675);
float randY14 = random(675);
float randY15 = random(675);
float randY16 = random(675);
float randY17 = random(675);
float randY18 = random(675);
float randY19 = random(675);
float randY20 = random(675);
float randY21 = random(675);
float randY22 = random(675);
//Size
float randSize1 = random (50, 250);
float randSize2 = random (170, 100);
float randSize3 = random (75, 150);
float randSize4 = random (50,150);
float birdSize1 = 100;
float speed1 = 4;
float speed2 = 7;
float speed3 = 1.4;
float speed4 = .5;
float speedYou = 2;
float gravYou = 4;
float gravity = .001;
void setup() {
size(1450, 675);
background(180, 0, 0);
You = loadImage(“TrumpFace.png”);
pic2 = loadImage(“CNNLogo.png”);
pic4 = loadImage(“ElectionDay.png”);
}

void draw() {
noStroke();
fill(30, 200, 40);
background(200, 200, 200);
fill(50,10,233);
image(pic4, 1355,0,100,700);
rect (5,2,480,125);
drawBird();
titleText ();
CollisionDetection();

}
void drawBirds (float X, float Y, float Size1, float bSize1) {
image (pic2, X, Y, Size1, bSize1);
X = X – speed1;
}
void drawBird (){
image (You, YouX, YouY, 75, 66);
YouY = YouY + gravYou;
gravYou = gravYou + gravity;
drawBirds(randX, randY, randSize1, randSize1);
drawBirds(randX2, randY2, randSize2, randSize2);
drawBirds(randX3, randY3, randSize2, randSize2);
drawBirds(randX4, randY4, randSize1, randSize1);
drawBirds(randX5, randY5, randSize3, randSize3);
drawBirds(randX6, randY6, randSize3, randSize3);
drawBirds(randX7, randY7, randSize2, randSize2);
drawBirds(randX8, randY8, randSize1, randSize1);
drawBirds(randX9, randY9, randSize1, randSize1);
drawBirds(randX10, randY10, randSize1, randSize1);
drawBirds(randX11, randY11, randSize3, randSize3);
drawBirds(randX12, randY12, randSize3, randSize3);
drawBirds(randX13, randY13, randSize1, randSize1);
drawBirds(randX14, randY14, randSize2, randSize2);
drawBirds(randX15, randY15, randSize2, randSize2);
drawBirds(randX16, randY16, randSize3, randSize3);
drawBirds(randX17, randY17, randSize3, randSize3);
drawBirds(randX18, randY18, randSize1, randSize1);
drawBirds(randX19, randY19, randSize3, randSize3);
drawBirds(randX20, randY20, randSize2, randSize2);
drawBirds(randX21, randY21, randSize1, randSize1);
drawBirds(randX22, randY22, randSize4, randSize4);
moveBirds ();
moveYou();
}

void moveBirds () {
randX = randX – speed1;
randX2 = randX2 – speed3;
randX3 = randX3 – speed3;
randX4 = randX4 – speed1;
randX5 = randX5 – speed2;
randX6 = randX6 – speed3;
randX7 = randX7 – speed2;
randX8 = randX8 – speed1;
randX9 = randX9 – speed3;
randX10 = randX10 – speed2;
randX11 = randX11 – speed1;
randX12 = randX12 – speed1;
randX13 = randX13 – speed2;
randX14 = randX14 – speed2;
randX15 = randX15 – speed1;
randX16 = randX16 – speed1;
randX17 = randX17 – speed3;
randX18 = randX18 – speed2;
randX19 = randX19 – speed2;
randX20 = randX20 – speed3;
randX21 = randX21 – speed2;
randX22 = randX22 – speed4;

}
void moveYou () {
//YouY = YouY+speedYou;
YouX = YouX+speedYou;
}

void keyPressed() {
YouY = YouY-45;

}

void CollisionDetection(){
float distance = dist(YouX,YouY,randX,randY);
float distance2 = dist(YouX,YouY,randX2,randY2);
float distance3 = dist(YouX,YouY,randX3,randY3);
float distance4 = dist(YouX,YouY,randX4,randY4);
float distance5 = dist(YouX,YouY,randX5,randY5);
float distance6 = dist(YouX,YouY,randX6,randY6);
float distance7 = dist(YouX,YouY,randX7,randY7);
float distance8 = dist(YouX,YouY,randX8,randY8);
float distance9 = dist(YouX,YouY,randX9,randY9);
float distance10 = dist(YouX,YouY,randX10,randY10);
float distance11 = dist(YouX,YouY,randX11,randY11);
float distance12 = dist(YouX,YouY,randX12,randY12);
float distance13 = dist(YouX,YouY,randX13,randY13);
float distance14 = dist(YouX,YouY,randX14,randY14);
float distance15 = dist(YouX,YouY,randX15,randY15);
float distance16 = dist(YouX,YouY,randX16,randY16);
float distance17 = dist(YouX,YouY,randX17,randY17);
float distance18 = dist(YouX,YouY,randX18,randY18);
float distance19 = dist(YouX,YouY,randX19,randY19);
float distance20 = dist(YouX,YouY,randX20,randY20);
float distance21 = dist(YouX,YouY,randX21,randY21);
float distance22 = dist(YouX,YouY,randX22,randY22);

int diam1 = 30;
int diam2 = 30;
if (distance < diam1+diam2){
YouX = YouX-10;
}

//0
if (distance < diam1+diam2){
YouX = YouX-10;
}

//1
if (distance2 < diam1+diam2){
YouX = YouX-10;

}

//2
if (distance3 < diam1+diam2){
YouX = YouX-10;
}

//3
if (distance4 < diam1+diam2){
YouX = YouX-10;
}

//4
if (distance5 < diam1+diam2){
YouX = YouX-10;
}

//5
if (distance6 < diam1+diam2){
YouX = YouX-10;
}

//6
if (distance7 < diam1+diam2){
YouX = YouX-10;
}

//7
if (distance8 < diam1+diam2){
YouX = YouX-10;
}

//8
if (distance9 < diam1+diam2){
YouX = YouX-10;
}

//9
if (distance10 < diam1+diam2){
YouX = YouX-10;
}

//10
if (distance11 < diam1+diam2){
YouX = YouX-10;
}

//11
if (distance12 < diam1+diam2){
YouX = YouX-10;

}
//12
if (distance13 < diam1+diam2){
YouX = YouX-10;

}
//13
if (distance14 < diam1+diam2){
YouX = YouX-10;

}
//14
if (distance15 < diam1+diam2){
YouX = YouX-10;

}
//15
if (distance16 < diam1+diam2){
YouX = YouX-10;

}
//16
if (distance17 < diam1+diam2){
YouX = YouX-10;

}
//17
if (distance18 < diam1+diam2){
YouX = YouX-10;

}
//18
if (distance19 < diam1+diam2){
YouX = YouX-10;

}
//19
if (distance20 < diam1+diam2){
YouX = YouX-10;

}
//20
if (distance21 < diam1+diam2){
YouX = YouX-10;

}
//46
if (distance22 < diam1+diam2){
YouX = YouX-10;
}

//END
if (YouX >= 1270){
textSize(100);
fill(0, 0, 0);
text(“America Loses”, 400, 300);

}

}

void titleText() {
textSize(32);
fill(225, 225, 225);
text(“ELECTION DAY”, 20, 30);
textSize(28);
fill(225, 225, 225);
text(“Directions:”, 18, 60);
textSize(22);
fill(225, 225, 225);
text(“Press keys repeatedly to move up”, 30, 90);
textSize(22);
fill(225, 225, 225);
text(“Avoid press conferences until Election Day”, 30, 120);
}

 

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