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

My Game, “Pacman’s Escape…?”

Leave a comment

Here ya go

Boolean collision=false;
Boolean button=false;
Ghost1[] ghost1 = new Ghost1[1]; //was wanderer
Ghost2[] ghost2 = new Ghost2[1]; //was manderer
Ghost3[] ghost3 = new Ghost3[1]; //new ghost!!!
Ghost4[] ghost4 = new Ghost4[1]; //final ghost :3

String d = “Dead!!!”;
String b = “Finally, after 36 years, Pacman has escaped the maze. He is finally free,”;
String b2= “but the ghosts of his past still haunt him. Help Pacman avoid these ghosts!”;
String p= “Start”;
String t= “His past will never disappear.”;
String c= “The ghosts hurt,”;
String c2= “but only you can kill you.”;

float gx=50;
float gy=100;
float x1=0;
float y1=0;
float x2=5;
float y2=0;
float diam1=50;
float diam2=60;
float diam3=70;
float diam4=80;
float speed1=1;
float speed2=5;
float speed3=10;
float speedMAN=15;
float score=0;
float screens=0;
float bx=10;
float by=300;
float bx2=15;
float by2=330;
float buttonx=300;
float buttony=475;
float buttonh=50;
float buttonw=100;
float cx=450;
float cy=500;

color black=color(0,0,0);
color white=color(255,255,255);
color red=color(255,0,0);
color purple=color(119,0,255);
color blue=color(0,77,255);
color yellow=color(255,230,0);

PImage img;

void setup(){
//background(black);
size(600,600);
img = loadImage(“Ghosts.png”);

for(int i=0; i<ghost1.length; i++){
ghost1[i] = new Ghost1(random(width), random(height));
}

for(int i=0; i<ghost2.length; i++){
ghost2[i] = new Ghost2(random(width), random(height));
}

for(int i=0; i<ghost3.length; i++){
ghost3[i] = new Ghost3(random(width), random(height));
}

for(int i=0; i<ghost4.length; i++){
ghost4[i] = new Ghost4(random(width), random(height));
}

}

void draw(){
background(0);
game();
WelcomeScreen();
DeathScreen();
Screens();
button();
WriteScoreAndTime();

}

void game(){
background(0);
Pacman(x1, y1, diam1, diam2);
//Ghosts(x2, y2, diam3, diam4);
//RepeatingGhosts();
//FlyingObjects();
//MoveFlyingObjects();
//FlyingFood();
//MoveFlyingFood();
//CollisionDetection();
//MoveGhosts();
ghost1();
ghost2();
ghost3();
ghost4();
}

///////////////////////////////////////////SCREEN CRAP/////////////////////////////////////////////////
void Screens(){
if (screens == 0){
WelcomeScreen();
}
else if (screens == 1){
game();
}
}

void WelcomeScreen(){
background(255);
fill(black);
textAlign(LEFT);
textSize(16);
text (b,bx,by);
text (b2,bx2,by2);
rect(buttonx-50,buttony,buttonw,buttonh);
fill(red);
text(p,buttonx-10,buttony+30,16);
}

void button(){
if(mouseX>buttonx && mouseX<(buttonx+buttonw) && mouseY>buttony && mouseY<(buttony+buttonh) && mousePressed){
button=true;
}
else{
button=false;
}
if(button){
screens=1;
}
}

void DeathScreen(){
background(0);
fill(white);
textAlign(LEFT);
textSize(50);
text (d, width/2, height/2);
}

/////////////////////////////////////ACTUAL GAME CRAP//////////////////////////////////////////////

////TimerCrap////
void WriteScoreAndTime(){
fill(white);
textSize(20);
text(t,50,height/6);
textSize(32);
//text(score,width/6,height/4);
text((millis()/1000),width/6,height/8);
textSize(20);
text (c, cx-30, cy);
text (c2, cx-90, cy+30);
}
///////GHOST CRAP/////////
void ghost1(){
for(int i=0; i<ghost1.length; i++){
ghost1[i].stayInsideCanvas();
ghost1[i].move();
//ellipse(wanderer[i].getX(),wanderer[i].getY(),50,100);
image(img,ghost1[i].getX(), ghost1[i].getY(),50,100);
}
}

void ghost2(){
for(int i=0; i<ghost2.length; i++){
ghost2[i].stayInsideCanvas();
ghost2[i].move();
image(img,ghost2[i].getX(), ghost2[i].getY(),gx,gy);
}
}

void ghost3(){
for(int i=0; i<ghost3.length; i++){
ghost3[i].stayInsideCanvas();
ghost3[i].move();
image(img,ghost3[i].getX(), ghost3[i].getY(),gx,gy);
}
}

void ghost4(){
for(int i=0; i<ghost4.length; i++){
ghost4[i].stayInsideCanvas();
ghost4[i].move();
image(img,ghost4[i].getX(), ghost4[i].getY(),gx,gy);
}
}

//ghost 4//
class Ghost4{
//hopefully functional ghosts
float gx;
float gy;
float wander_theta;
float wander_radius;
float max_wander_offset = 0.5;
float max_wander_radius = 4;

Ghost4(float _x, float _y){
gx= _x;
gy= _y;
wander_theta = random(TWO_PI);
wander_radius = random(max_wander_radius);
}

void stayInsideCanvas(){
gx %= width;
gy %= height;
}

void move()
{
float wander_offset = random(-max_wander_offset, max_wander_offset);
wander_theta += wander_offset;

gx += cos(wander_theta);
gy += sin(wander_theta);
}

float getX()
{
return gx;
}

float getY()
{
return gy;
}

void CollisionDetection(){
float distance=dist(x1,y1,x2,y2);
if (distance<gx+gy){
collision=true;
println(“crash”);
background(white);
score=score-1;
}
else{
collision=false;
}
}

void loopPlayer(){
if(gx>width){
gx=0;
}
else if(gx<0){
gx=width;
}
if(gy>height){
gy=0;
}
if(gy<0){
gy=height;
}
}
}

//ghost 3//
class Ghost3{
//hopefully functional ghosts
float gx;
float gy;
float wander_theta;
float wander_radius;
float max_wander_offset = 0.5;
float max_wander_radius = 4;

Ghost3(float _x, float _y){
gx= _x;
gy= _y;
wander_theta = random(TWO_PI);
wander_radius = random(max_wander_radius);
}

void stayInsideCanvas(){
gx %= width;
gy %= height;
}

void move()
{
float wander_offset = random(-max_wander_offset, max_wander_offset);
wander_theta += wander_offset;

gx += cos(wander_theta);
gy += sin(wander_theta);
}

float getX()
{
return gx;
}

float getY()
{
return gy;
}

void CollisionDetection(){
float distance=dist(x1,y1,x2,y2);
if (distance<gx+gy){
collision=true;
println(“crash”);
background(white);
score=score-1;
}
else{
collision=false;
}
}

void loopPlayer(){
if(gx>width){
gx=0;
}
else if(gx<0){
gx=width;
}
if(gy>height){
gy=0;
}
if(gy<0){
gy=height;
}
}
}

//ghost 2//
class Ghost2{
//hopefully functional ghosts
float x;
float y;
float mander_theta;
float mander_radius;
float max_mander_offset = 0.5;
float max_mander_radius = 4;

Ghost2(float _x, float _y){
x= _x;
y= _y;
mander_theta = random(TWO_PI);
mander_radius = random(max_mander_radius);
}

void stayInsideCanvas(){
x %= width;
y %= height;
}

void move()
{
float mander_offset = random(-max_mander_offset, max_mander_offset);
mander_theta += mander_offset;

x += cos(mander_theta);
y += sin(mander_theta);
}

float getX()
{
return x;
}

float getY()
{
return y;
}

void CollisionDetection(){
float distance=dist(x1,y1,x2,y2);
if (distance<gx+gy){
collision=true;
println(“crash”);
background(white);
score=score-1;
}
else{
collision=false;
}
}

void loopPlayer(){
if(gx>width){
gx=0;
}
else if(gx<0){
gx=width;
}
if(gy>height){
gy=0;
}
if(gy<0){
gy=height;
}
}
}

///ghost 1////
class Ghost1{
//hopefully functional ghosts
float gx;
float gy;
float wander_theta;
float wander_radius;
float max_wander_offset = 0.5;
float max_wander_radius = 4;

Ghost1(float _x, float _y){
gx= _x;
gy= _y;
wander_theta = random(TWO_PI);
wander_radius = random(max_wander_radius);
}

void stayInsideCanvas(){
gx %= width;
gy %= height;
}

void move()
{
float wander_offset = random(-max_wander_offset, max_wander_offset);
wander_theta += wander_offset;

gx += cos(wander_theta);
gy += sin(wander_theta);
}

float getX()
{
return gx;
}

float getY()
{
return gy;
}

void CollisionDetection(){
float distance=dist(x1,y1,x2,y2);
if (distance<gx+gy){
collision=true;
println(“crash”);
background(white);
score=score-1;
}
else{
collision=false;
}
}

void loopPlayer(){
if(gx>width){
gx=0;
}
else if(gx<0){
gx=width;
}
if(gy>height){
gy=0;
}
if(gy<0){
gy=height;
}
}
}

/////PacMan Crap//////
void keyPressed(){
if(key==CODED){
if(keyCode==DOWN){
y1=y1+speedMAN;
}
else if(keyCode==UP){
y1=y1-speedMAN;
}
else if(keyCode==RIGHT){
x1=x1+speedMAN;
}
else if(keyCode==LEFT){
x1=x1-speedMAN;
}
}
}

void Pacman(float x, float y, float w, float h){
fill(yellow);
ellipse(x+300,y+300,w,h);
}

/////collision crap////////
//void CollisionDetection(){
//i need that death screen tbh
//x1=0
//x2=5
//y1=0
//y2=0
//float distance=dist(x1,y1,x2,y2);
//if (distance<diam2+diam4){
//collision=true;
//fill(red);
//text(c,450,500);
//println(“crash”);
//background(white);
//}
//else{
//collision=false;
//}
//}

////////////////////////////////////THE DEAD ZONE CRAP///////////////////////////////////////////////
//void Ghosts(float x, float y, float w, float h){
//fill(blue);
//ellipse(x,y,w,h);
//}

//void MoveGhosts(){
//x2=x2+speed2;
//y2=y2+speed2;

//}

//void RepeatingGhosts(){
//for(int x=0; x<width; x+=50);
//}

//void FlyingObjects(){
//}

//void MoveFlyingObjects(){
//}

//void FlyingFood(){
//}

//void MoveFlyingFood(){
//}

 

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