xxxxxxxxxx
Monkey m1;
Banana b1;
LHand[] L = new LHand[12];
RHand[] R = new RHand[12];
int monkeyFrames = 18;
int moveX = 0;
int moveY = 0;
float timer = 0; //activates casting animation
float timer2 = 0; //ends casting animation
PImage[] Monkey = new PImage[monkeyFrames];
int control = 8;
int count = 0;
int endTimer = 0;
int handControl = 0;
int handFrames = 5;
PImage[] LeftHands = new PImage[handFrames];
PImage[] RightHands = new PImage[handFrames];
int bananaFrames = 5;
int bananaControl = 0;
PImage[] Banana = new PImage[bananaFrames];
PImage Background;
float score;
void setup() {
for (int i = 0; i < monkeyFrames; i++) {
Monkey[i] = loadImage("Monkey-"+i+".png");
}
for (int j = 0; j < handFrames; j++) {
LeftHands[j] = loadImage("LHand-"+j+".png");
}
for (int k = 0; k < handFrames; k++) {
RightHands[k] = loadImage("RHand-"+k+".png");
}
for (int l = 0; l < bananaFrames; l++) {
Banana[l] = loadImage("Banana-"+l+".png");
}
Background = loadImage("Background.png");
fullScreen();
m1 = new Monkey(1280, 1190);
b1 = new Banana();
for (int i = 0; i < L.length; i++) {
L[i] = new LHand();
}
for (int j = 0; j < R.length; j++) {
R[j] = new RHand();
}
score = 0;
frameRate(24);
}
void draw() {
if (control < 8) {
noCursor();
}
println(control);
background(150, 240, 255);
textMode(CENTER);
textSize(50);
fill(255);
text(score, width/2-84, 100);
imageMode(CENTER);
image(Background, width/2, height/2);
resetMatrix();
b1.display();
m1.display();
for (int j = 0; j < R.length; j++) {
R[j].standby();
}
for (int i = 0; i < L.length; i++) {
L[i].standby();
}
for (int n = 0; n < L.length; n++) {
if ((L[n].intersect(b1))) {
control = 6;
count = 0;
}
}
for (int o = 0; o < R.length; o++) {
if ((R[o].intersect(b1))) {
control = 6;
count = 0;
}
}
if (m1.intersect(b1)) {
control = 7;
count = 0;
}
if (control < 6) {
score = score + 0.041;
}
timer = random(360, 480);
if (timer < count && control == 0) {
control = 4;
}
if (endTimer >= 48) {
control = 8;
}
if (control == 8) {
cursor();
textSize(75);
text("CLICK TO START", width/2-290, 1380);
}
}
void mouseReleased() {
if (control == 8) {
control =0;
endTimer = 0;
}
}
class Banana {
int x = mouseX;
int y = mouseY;
int frames = 0;
Banana() {
}
void display() {
if (control == 8) {
bananaControl = 2;
}
if (control <= 7 && control >= 6){
bananaControl = 1;
}
if (control < 6){
bananaControl = 0;
}
if (bananaControl == 0) {
frames = 0;
x = constrain(mouseX, 360, 2200);
y = constrain(mouseY, 220, 1220);
image(Banana[frames], x, y);
}
if (bananaControl == 1) {
frames = 4;
x = width/2;
y = -30;
}
if (bananaControl == 2) {
x = width/2;
y = 1100;
image(Banana[frames], x, y);
frames = frames - 1;
if (frames <= 0) {
frames = 0;
}
}
}
}
class LHand {
float startingX;
float startingY;
int HmoveX = 40;
int frame = 0;
float handCount; //controls animtion time
float handTimer = 144; //animation time limit
LHand() {
}
void standby() {
if (handControl == 0) {
startingX = random(-2560, -57);
startingY = random(220, 1000);
handCount = 0;
if (control == 5) {
handControl = 1;
}
if (control == 6) {
handControl = 2;
}
}
if (handControl == 1) {
image(LeftHands[frame], startingX, startingY);
startingX = startingX + HmoveX;
handCount = handCount + 1;
if (handCount >= handTimer) {
handCount = 0;
handControl = 0;
}
if (control == 6) {
handControl = 2;
}
}
if (handControl == 2) {
image(LeftHands[frame], startingX, startingY);
startingX = startingX + HmoveX;
frame = frame +1;
if (frame >= 4) {
frame = 4;
}
}
if (handControl == 3){
image(LeftHands[frame], startingX, startingY);
startingX = startingX + HmoveX;
}
}
boolean intersect(Banana b1) {
float d = dist(startingX, startingY, mouseX, mouseY);
if ((d>0) && (d < 50)) {
return true;
} else {
return false;
}
}
}
class Monkey {
float x;
float y;
int frameCounter = 17;
int Xincrement;
int Yincrement;
//float xCoordinate = (moveX+x);
Monkey(float a, float b) {
x = a;
y = b;
}
void display() {
image(Monkey[frameCounter], (moveX+x), (moveY+y));
finiteProbabilityDrive();
}
void finiteProbabilityDrive() {
//println(frameCounter);
int maxFrame;
int minFrame;
count = count + 1;
if (control == 0) {
if (Xincrement > 0) {
maxFrame = 2;
minFrame = 0;
} else {
maxFrame = 4;
minFrame = 2;
}
frameCounter = frameCounter+1;
if (frameCounter >= maxFrame) {
frameCounter = minFrame;
if ((moveX+x) > mouseX) {
Xincrement = -20;
}
if ((moveX+x) < mouseX) {
Xincrement = 20;
}
if ((moveX+x) <= 380) {
moveX = -900;
}
if ((moveX+x) >= 2180) {
moveX = 900;
}
if ((moveX+x) == mouseX) {
control = 2;
}
if ((moveX+x) > mouseX && (moveX+x+Xincrement) < mouseX) {
control = 2;
}
if ((moveX+x) < mouseX && (moveX+x+Xincrement) > mouseX) {
control = 2;
}
moveX = moveX + Xincrement;
}
}
if (control == 2) {
Yincrement = -60;
if ((moveY+y) >= 290 && (moveY+y) <= 1190) {
moveY = moveY+Yincrement;
moveX = moveX + Xincrement;
if ((moveX+x) <= 380) {
moveX = -900;
}
if ((moveX+x) >= 2180) {
moveX = 900;
}
if ((moveX+x) > mouseX) {
frameCounter = 4;
Xincrement = -15;
}
if ((moveX+x) < mouseX) {
Xincrement = 15;
frameCounter = 5;
}
} else {
control = 3;
}
}
if (control == 3) {
Yincrement = 70;
if ((moveX+x) <= 380) {
moveX = -900;
}
if ((moveX+x) >= 2180) {
moveX = 900;
}
if ((moveY+y) >= 0 && (moveY+y) <= 1110) {
moveY = moveY+Yincrement;
moveX = moveX + Xincrement;
} else {
moveY = 0;
control = 0;
}
}
if (control == 4) {
frameCounter = 6;
control = 5;
Yincrement = -1;
}
if (control == 5) {
frameCounter = frameCounter + 1;
minFrame = 8;
maxFrame = 13;
frameCounter = frameCounter+1;
if (frameCounter >= maxFrame) {
frameCounter = minFrame;
}
moveY = moveY + Yincrement;
if (moveY <= -16) {
Yincrement = 1;
}
if (moveY >= 1) {
Yincrement = -1;
}
timer2 = timer2 + 1;
if (timer2 >= 48) {
count = 0;
timer2 = 0;
control = 0;
}
}
if (control == 6) {
endTimer = endTimer + 1;
if (moveX > 0) {
Xincrement = -20;
moveX = moveX + Xincrement;
maxFrame = 4;
minFrame = 2;
frameCounter = frameCounter+1;
if (frameCounter >= maxFrame) {
frameCounter = minFrame;
}
if (moveX <= 0) {
moveX = 0;
}
}
if (moveX < 0) {
Xincrement = 20;
moveX = moveX + Xincrement;
maxFrame = 2;
minFrame = 0;
frameCounter = frameCounter+1;
if (frameCounter >= maxFrame) {
frameCounter = minFrame;
}
if (moveX >= 0) {
moveX = 0;
}
}
if (moveY < 0) {
moveY = moveY + 70;
}
if (moveY >=0) {
moveY = 0;
}
if (moveX == 0) {
frameCounter = 13;
}
}
if (control == 7) {
endTimer = endTimer + 1;
if (moveX > 0) {
Xincrement = -20;
moveX = moveX + Xincrement;
maxFrame = 4;
minFrame = 2;
frameCounter = frameCounter+1;
if (frameCounter >= maxFrame) {
frameCounter = minFrame;
}
if (moveX <= 0) {
moveX = 0;
}
}
if (moveX < 0) {
Xincrement = 20;
moveX = moveX + Xincrement;
maxFrame = 2;
minFrame = 0;
frameCounter = frameCounter+1;
if (frameCounter >= maxFrame) {
frameCounter = minFrame;
}
if (moveX >= 0) {
moveX = 0;
}
}
if (moveY < 0) {
moveY = moveY + 70;
}
if (moveY >=0) {
moveY = 0;
}
if (moveX == 0) {
frameCounter = 13;
}
}
if (control == 8) {
frameCounter = frameCounter+1;
if (frameCounter >= 17) {
frameCounter = 17;
}
}
}
boolean intersect(Banana b1) {
float d = dist((moveX+x), (moveY+y), mouseX, mouseY);
if ((d>0) && (d < 40)) {
return true;
} else {
return false;
}
}
}
class RHand {
float startingX;
float startingY;
int HmoveX = -40;
int frame = 0;
float handCount;
float handTimer = 144;
RHand() {
}
void standby() {
if (handControl == 0) {
startingX = random(2617, 5120);
startingY = random(220, 1000);
handCount = 0;
if (control == 5) {
handControl = 1;
}
}
if (handControl == 1) {
image(RightHands[frame], startingX, startingY);
startingX = startingX + HmoveX;
handCount = handCount + 1;
if (handCount >= handTimer) {
handCount = 0;
handControl = 0;
}
if (control == 6) {
handControl = 2;
}
}
if (handControl == 2) {
image(RightHands[frame], startingX, startingY);
startingX = startingX + HmoveX;
frame = frame +1;
if (frame >= 4) {
frame = 4;
}
}
if (handControl == 3) {
image(RightHands[frame], startingX, startingY);
startingX = startingX + HmoveX;
}
}
boolean intersect(Banana b1) {
float d = dist(startingX, startingY, mouseX, mouseY);
if ((d>0) && (d < 40)) {
return true;
} else {
return false;
}
}
}