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

Game Project: Fly Guy

Leave a comment

screen-shot-2016-10-20-at-3-57-06-pm

float ly =200;

float Ryspeed = 1;

float keySpeed = 50;

boolean collision = false;

float score =100;

void setup(){
size(400,700);

}

void draw(){
background(188,226,255);
//head
fill(#B49E71);
ellipse(300,200,300,300);
//eyes
fill(255);
ellipse(280,200,100,100);
ellipse(350,200,100,100);
//pupils
fill(0);
ellipse(280,230,50,50);
ellipse(350,230,50,50);
//brows
line(230,100,300,150);
line(320,150,380,100);
FlyGuy(x,y,body);
RightFlySwatterB(Rx,Ry,Rw);
RightFlySwatterT(R2x,R2y,Rw);
LeftFlySwatter(R3x,R3y,R3w);
//LeftFlySwatter(R4x,R4y,R4w);
//moveFly();
moveSwatter();
increaseSwatterSpeed();
loopPlayerRect();
CollisionDetection();
CollisionDetection2();
WriteScoreAndTime();
}

void FlyGuy( float x,float y, float body){

//wings

fill(255,255,255);

ellipse((x+10),(y+355),(body/2),(body*.8));

ellipse((x-15),(y+355),(body/2),(body*.8));

//body

fill(234,166,38);

ellipse(x,y+405,body,(body*.6));

//eyes

fill(255,255,255);

ellipse(x+40,y+393,(body*.3),(body*.3));

ellipse(x+20,y+395,(body*.3) ,(body*.3));

//pupils

fill(0,0,0);

ellipse(x+20,y+405,(body*.10),(body*.10));

ellipse(x+45,y+400,(body*.1),(body*.1));

//mouth

fill(230,30,40);

arc(x+30, y+420, (body*.3), (body*.3), 0, PI+QUARTER_PI, CHORD);

//leg

line(x-5,y+435,x-20,y+460);

//other leg

line(x+10,y+435,x+5,y+460);

}
//void moveFly(){
//x = x-speed;
//}

void keyPressed(){

if (keyCode == RIGHT){

x = x + keySpeed;

}

else if (keyCode == LEFT){

x = x -keySpeed;

} }

void RightFlySwatterB (float Rx, float Ry, float Rw){
strokeWeight(3);

//right side
//bottom
fill(255,255,255);

rect(Rx,Ry,Rw,Rw);

line(Rx+100,Ry+50,Rx+190,Ry+50);
}

//top
void RightFlySwatterT (float R2x, float R2y, float Rw){
fill(255,255,255);

rect(R2x,R2y,Rw,Rw);

line(R2x+100,R2y+50,R2x+200,R2y+50);
}

void LeftFlySwatter(float R3x, float R3y, float Rw){
//left side
//bottom
fill(255,255,255);
rect(R3x,R3y,Rw,Rw);
line(R3x-50,R3y+50,R3x,R3y+50);

//top
//fill(255,255,255);

//rect(R4x-150,R4y-200,R4w,R4w);

//line(R4x-200,R4y-150,R4x-150,R4y-150);
}

void moveSwatter(){

Ry = Ry+ Ryspeed;
R2y = R2y+ Ryspeed;
R3y = R3y+ Ryspeed;
// R4y = R4y+ Ryspeed;

}

void increaseSwatterSpeed(){
Ryspeed = Ryspeed + 0.002;
}
void CollisionDetection(){
float distance1 =dist(x2,y2,Rx,Ry);
float distance2 = dist(x2,y2,R2x,R2y);
//float distance3 = dist(x2,y2,R3x,R3y);
//float distance4 = dist(x,y,R4x,R4y);
if (distance1 < Rw ||distance2 < Rw){
collision =true;
println(“swat”);
score = score – 1;
}
else{
collision = false;
}
}
void CollisionDetection2(){
float distance3 = dist(x2,y2,(R3x*2),(R3y*2));
if (distance3 < Rw){
collision =true;
println(“swat”);
score = score – 1;
}
else{
collision = false;
}
}

void loopPlayerRect(){
if (Ry > height){
Ry=0;
}

if (R3y > height){
R3y=0;
}

// if (R4y > height){
// R4y=0;
// }

if (R2y > height){
R2y=0;
}
}
void WriteScoreAndTime(){
fill(0);
textSize(18);
text(“Help FlyGuy avoid the Swatters!”,width/6,height/10);
textSize(32);
text(score,width/6,height/6);
}

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