- int speed = 8;
int x = 100; // x location of fly - int y = 100; // y location of fly
- int state = 0;
- void setup() {
size (800,700);
PFont myfont;
myfont = createFont("Ariel",18);
} - void draw () {
cursor(CROSS);
strokeWeight(1);
background(161,140,198);
// Display the square
stroke(0);
fill(100);
fill (209,120,25);
rect(0,350,800,700);
fill(175);
//spider head
fill (0,mouseY,mouseX);
ellipse (530,470,70,50);
fill (255);
ellipse (510,470,10,20);
fill(0);
ellipse (510,470,5,6);
//spider body
fill(mouseX,mouseY,0);
ellipse (600,500,120,100);
//spider legs
strokeWeight (6);
line (550,530,450,500);
line (570,544,470,550);
line (590,550, 540,590);
line(450,500,380,560);
line(470,550,400,620);
line (540,590,500,650);
//right hand side legs
line(600,450, 650,400);
line (630,454, 680,420);
line (653,470, 700,440);
line(650,400,730,380);
line(680,420,770,440);
line(700,440,800,490);
strokeWeight (1);
//fly
strokeWeight (0);
fill (255);
ellipse(x,y-10,40,20);
fill(170);
ellipse(x,y,40,20);
fill(0);
ellipse(x+10,y,20,10);
//cross hairs
line (mouseX-30,mouseY,mouseX-10,mouseY);
line (mouseX+30,mouseY,mouseX+10,mouseY);
line (mouseX,mouseY+30,mouseX,mouseY+10);
line (mouseX,mouseY-30,mouseX,mouseY-10);
- //path of fly
- if (state == 0) {
x = x + speed;
if (x > width-100) {
x = width-100;
state = 1;
}
} else if (state == 1) {
y = y + speed;
if (y > height-100) {
y = height-100;
state = 2;
}
} else if (state == 2) {
x = x - speed;
if (x < 150) {
x = 150;
state = 3;
}
} else if (state == 3) {
y = y - speed;
if (y<200) {
y = 200;
state= 4;
}
} else if (state == 4) {
x = x + speed;
if (x>600) {
x = 600;
state=5;
}
}
else if (state == 5) {
y = y + speed;
if (y > 400) {
y = 400;
state=6;
}
}
else if (state == 6) {
x = x - speed;
if (x < 500) {
x = 500;
state=7;
}
}
else if (state ==7) {
y = y - speed;
if (y < 100) {
y = 100;
state=0;
}
}
if (state == 0) {
x = x + speed;- if (x > width-100) {
x = width-100;
state = 1;
}
}strokeWeight(2);
if (mousePressed == true) {
line(495,470,mouseX,mouseY);
}
}
-
it may be a bit noobish,i know, but im following some processing tutorials at the moment and want to learn how to use it properly-
-
its a basic game - if u click-the spider shoots a web
-
my problem is....if i click on the fly...and only the fly< as if the spider was catching it>
-
how would i get a text to count it as a score....1...2..3..4 etc only when the fly is clicked.
-
not looking for any answers or anything, just want to learn how to do this
1