///////////////////////////////////////////////
//////Fred the Chicken by: Rebecca Cooke///////
///////click(or dont click) the chicken////////
///////////////////////////////////////////////
Chicken fred;
AngryChicken angryFreds;
AngryChicken[]manyFreds = new AngryChicken[25];
PVector fredPosition;
PVector fredSpeed;
PVector angryFredsPosition;
PVector angryFredsSpeed;
int timer;
void setup() {
size(800, 600);
frameRate(60);
rectMode(CENTER);
//The chicken moving (Fred the Chicken)
fredPosition = new PVector(200, 200);
fredSpeed = new PVector(2, 2);
fred = new Chicken(fredPosition, fredSpeed);
//Spawing Angry Chickens
for (int i = 0; i < 25; i ++) {
angryFredsPosition = new PVector(random(100, 400), random(100, 200));
angryFredsSpeed = new PVector(random(2,20), random(2, 20));
manyFreds[i] = new AngryChicken(angryFredsPosition, angryFredsSpeed);
}
}
void draw() {
//Draw grass with little grass tuffs
background(85, 175, 90);
stroke(62, 134, 66);
strokeWeight(4);
beginShape();
line(605, 210, 580, 145);
line(580, 145, 630, 185);
line(630, 185, 660, 135);
line(660, 135, 660, 185);
line(660, 185, 660, 185);
line(660, 185, 715, 155);
line(715, 155, 675, 215);
endShape();
beginShape();
line(555, 510, 530, 445);
line(530, 445, 580, 485);
line(580, 485, 610, 435);
line(610, 435, 610, 485);
line(610, 485, 610, 485);
line(610, 485, 665, 455);
line(665, 455, 625, 515);
endShape();
beginShape();
line(105, 310, 80, 245);
line(80, 245, 130, 285);
line(130, 285, 160, 235);
line(160, 235, 160, 285);
line(160, 285, 160, 285);
line(160, 285, 215, 255);
line(215, 255, 175, 315);
fred.doodle();
fred.run();
//Calling all angry chickens
for (int i = 0; i < 25; i ++) {
manyFreds[i].angryDoodle();
manyFreds[i].madRun();
}
}
void mousePressed() {
if (mouseX < fred.position.x + 300 && mouseX > fred.position.x + 100 && mouseY > fred.position.y + 100 && mouseY < fred.position.y + 300) {
for (int i = 0; i < 25; i ++) {
manyFreds[i].visable = true;
fred.fredVisible = false;
}
}
}class AngryChicken{
PVector angryPos;
PVector angrySpeed;
PVector angryDirection;
boolean visable = false;
AngryChicken(PVector cPosition, PVector cSpeed){
angryPos = cPosition;
angrySpeed = cSpeed;
angryDirection = new PVector(1, 1);
}
void angryDoodle(){
if (visable == true){
//Draw angry Fred
noStroke();
fill(234,120,97);
ellipse(angryPos.x + 190,angryPos.y + 195,220,220);
stroke(0);
strokeWeight(2);
//Tail
fill(234,120,97);
beginShape();
curveVertex(angryPos.x + 200,angryPos.y + 135);
curveVertex(angryPos.x + 168,angryPos.y + 145);
curveVertex(angryPos.x + 142,angryPos.y + 94);
curveVertex(angryPos.x + 170,angryPos.y + 75);
endShape();
beginShape();
curveVertex(angryPos.x + 180,angryPos.y + 100);
curveVertex(angryPos.x + 142,angryPos.y + 94);
curveVertex(angryPos.x + 95,angryPos.y + 140);
curveVertex(angryPos.x + 100,angryPos.y + 202);
curveVertex(angryPos.x + 140,angryPos.y + 202);
endShape();
//Bigger line for the head
fill(234,120,97);
beginShape();
curveVertex(angryPos.x + 220,angryPos.y + 140);
curveVertex(angryPos.x + 200,angryPos.y + 125);
curveVertex(angryPos.x + 168,angryPos.y + 145);
curveVertex(angryPos.x + 160,angryPos.y + 168);
curveVertex(angryPos.x + 160,angryPos.y + 168);
endShape();
//Red fluff ontop of head
fill(208,64,32);
beginShape();
curveVertex(angryPos.x + 200,angryPos.y + 125);
curveVertex(angryPos.x + 200,angryPos.y + 125);
curveVertex(angryPos.x + 190,angryPos.y + 100);
curveVertex(angryPos.x + 240,angryPos.y + 92);
curveVertex(angryPos.x + 270,angryPos.y + 130);
curveVertex(angryPos.x + 262,angryPos.y + 148);
curveVertex(angryPos.x + 200,angryPos.y + 125);
curveVertex(angryPos.x + 200,angryPos.y + 125);
endShape();
//Smaller line for the head
fill(234,120,97);
beginShape();
curveVertex(angryPos.x + 240,angryPos.y + 148);
curveVertex(angryPos.x + 262,angryPos.y + 148);
curveVertex(angryPos.x + 262,angryPos.y + 175);
curveVertex(angryPos.x + 240,angryPos.y + 175);
endShape();
//Right foot
fill(248,184,40);
ellipse(angryPos.x + 240,angryPos.y + 295,40,15);
//Bottom
fill(234,120,97);
beginShape();
curveVertex(angryPos.x + 245,angryPos.y + 230);
curveVertex(angryPos.x + 255,angryPos.y + 264);
curveVertex(angryPos.x + 205,angryPos.y + 305);
curveVertex(angryPos.x + 142,angryPos.y + 280);
curveVertex(angryPos.x + 130,angryPos.y + 238);
curveVertex(angryPos.x + 130,angryPos.y + 238);
endShape();
//Left foot
fill(248,184,40);
ellipse(angryPos.x + 148,angryPos.y + 290,40,20);
//Feathers
fill(234,120,97);
beginShape();
curveVertex(angryPos.x + 272,angryPos.y + 238);
curveVertex(angryPos.x + 272,angryPos.y + 238);
curveVertex(angryPos.x + 295,angryPos.y + 212);
curveVertex(angryPos.x + 308,angryPos.y + 180);
curveVertex(angryPos.x + 290,angryPos.y + 162);
curveVertex(angryPos.x + 260,angryPos.y + 175);
curveVertex(angryPos.x + 260,angryPos.y + 175);
endShape();
beginShape();
curveVertex(angryPos.x + 165,angryPos.y + 240);
curveVertex(angryPos.x + 165,angryPos.y + 240);
curveVertex(angryPos.x + 130,angryPos.y + 238);
curveVertex(angryPos.x + 85,angryPos.y + 210);
curveVertex(angryPos.x + 88,angryPos.y + 168);
curveVertex(angryPos.x + 128,angryPos.y + 155);
curveVertex(angryPos.x + 162,angryPos.y + 172);
curveVertex(angryPos.x + 180,angryPos.y + 198);
curveVertex(angryPos.x + 180,angryPos.y + 198);
endShape();
//Red fluff under beak
fill(208,64,32);
ellipse(angryPos.x + 255,angryPos.y + 230,40,70);
//Beak
fill(248,184,40);
triangle(angryPos.x + 262,angryPos.y + 175,angryPos.x + 285,angryPos.y + 200,angryPos.x + 232,angryPos.y + 200);
//Eyeball
noStroke();
fill(0);
rect(angryPos.x + 210,angryPos.y + 175,10,30);
}
}
void madRun(){
// Keeping the chicken within the frame
angryPos.x = angryPos.x + ( angrySpeed.x * angryDirection.x );
angryPos.y = angryPos.y + ( angrySpeed.y * angryDirection.y );
if (angryPos.x + 200 > width-85 || angryPos.x + 85 < 0) {
angryDirection.x *= -1;
}
if (angryPos.y +200 > height-95 || angryPos.y + 95 < 0) {
angryDirection.y *= -1;
}
}
}class Chicken {
PVector position;
PVector speed;
PVector direction;
boolean fredVisible = true;
Chicken(PVector cPosition, PVector cSpeed) {
position = cPosition;
speed = cSpeed;
direction = new PVector(1, 1);
}
void doodle() {
if (fredVisible == true) {
//Draw Fred the chicken
noStroke();
fill(255);
ellipse(position.x + 190, position.y + 195, 220, 220);
stroke(0);
strokeWeight(2);
//Tail
fill(255);
beginShape();
curveVertex(position.x + 200, position.y + 135);
curveVertex(position.x + 168, position.y + 145);
curveVertex(position.x + 142, position.y + 94);
curveVertex(position.x + 170, position.y + 75);
endShape();
beginShape();
curveVertex(position.x + 180, position.y + 100);
curveVertex(position.x + 142, position.y + 94);
curveVertex(position.x + 95, position.y + 140);
curveVertex(position.x + 100, position.y + 202);
curveVertex(position.x + 140, position.y + 202);
endShape();
//Bigger line for the head
fill(255);
beginShape();
curveVertex(position.x + 220, position.y + 140);
curveVertex(position.x + 200, position.y + 125);
curveVertex(position.x + 168, position.y + 145);
curveVertex(position.x + 160, position.y + 168);
curveVertex(position.x + 160, position.y + 168);
endShape();
//Red fluff ontop of head
fill(208, 64, 32);
beginShape();
curveVertex(position.x + 200, position.y + 125);
curveVertex(position.x + 200, position.y + 125);
curveVertex(position.x + 190, position.y + 100);
curveVertex(position.x + 240, position.y + 92);
curveVertex(position.x + 270, position.y + 130);
curveVertex(position.x + 262, position.y + 148);
curveVertex(position.x + 200, position.y + 125);
curveVertex(position.x + 200, position.y + 125);
endShape();
//Smaller line for the head
fill(255);
beginShape();
curveVertex(position.x + 240, position.y + 148);
curveVertex(position.x + 262, position.y + 148);
curveVertex(position.x + 262, position.y + 175);
curveVertex(position.x + 240, position.y + 175);
endShape();
//Right foot
fill(248, 184, 40);
ellipse(position.x + 240, position.y + 295, 40, 15);
//Bottom
fill(255);
beginShape();
curveVertex(position.x + 245, position.y + 230);
curveVertex(position.x + 255, position.y + 264);
curveVertex(position.x + 205, position.y + 305);
curveVertex(position.x + 142, position.y + 280);
curveVertex(position.x + 142, position.y + 250);
endShape();
//Left foot
fill(248, 184, 40);
ellipse(position.x + 170, position.y + 305, 40, 20);
//Feather
fill(255);
beginShape();
curveVertex(position.x + 165, position.y + 240);
curveVertex(position.x + 165, position.y + 240);
curveVertex(position.x + 142, position.y + 280);
curveVertex(position.x + 100, position.y + 280);
curveVertex(position.x + 85, position.y + 240);
curveVertex(position.x + 100, position.y + 202);
curveVertex(position.x + 122, position.y + 185);
curveVertex(position.x + 122, position.y + 185);
endShape();
//Red fluff under beak
fill(208, 64, 32);
ellipse(position.x + 255, position.y + 230, 40, 70);
//Beak
fill(248, 184, 40);
triangle(position.x + 262, position.y + 175, position.x + 285, position.y + 200, position.x + 232, position.y + 200);
//Eyeball
noStroke();
fill(0);
rect(position.x + 210, position.y + 175, 10, 30*(sin(frameCount*.1)));
}
}
void run() {
// Keeping the chicken within the frame
position.x = position.x + ( speed.x * direction.x );
position.y = position.y + ( speed.y * direction.y );
if (position.x + 200 > width-85 || position.x + 85 < 0) {
direction.x *= -1;
}
if (position.y +200 > height-95 || position.y + 95 < 0) {
direction.y *= -1;
}
}
}