In the game, 2 monkeys or 1 (that already works) should be falling down but with my code one monkey is stuck in the top left corner flickering (blinking)
int monkeyaY = -50;
int monkeybY = -50;
int monkeya_X = 0;
int monkeyb_X = 0;
int monkeyWidth = 76;
int Counter;
int Score;
int netLeft = 0;
int netWidth = 118;
int NetPointPos = 0;
int randDelay = 0;
int fallType = 0;
int randSpeed = 0;
void Imgs() {
fallType = (int) random(0,3);
PImage img;
img = loadImage("background.png");
background(img);
randDelay = (int) random(0,100);
PImage monkey = loadImage("Monkey.png");
if(fallType == 0){
image(monkey, monkeya_X, monkeyaY);
}else if(fallType == 1){
image(monkey, monkeya_X, monkeyaY);
delay(randDelay);
image(monkey, monkeyb_X, monkeybY);
}else if(fallType == 2){
image(monkey, monkeya_X, monkeyaY);
delay(50);
image(monkey, monkeyb_X, monkeybY);
}else if(fallType == 3){
delay(randDelay);
image(monkey, monkeya_X, monkeyaY);
}
PImage net = loadImage("Net.png");
NetPointPos = mouseX - netWidth/2;
netLeft = mouseX - netWidth/2;
image(net, NetPointPos, 275);
}
void setup() {
size(1024, 386);
PImage img;
img = loadImage("background.png");
background(img);
PImage cursor = loadImage("Cursor.png");
cursor(cursor);
fallType = (int) random(0,3);
}
void draw() {
Imgs();
if (monkeyaY < 300) {
monkeyaY += (int) random(5,6);
} else {
monkeya_X = (int)random(30, 915);
monkeyaY = -50;
}
if (monkeybY < 300) {
monkeyaY += (int) random(5,6);
} else {
monkeyb_X = (int)random(30, 915);
monkeybY = -50;
}
if (monkeya_X >= netLeft && netLeft + netWidth >= monkeya_X + monkeyWidth && monkeyaY == 300 | monkeyb_X >= netLeft && netLeft + netWidth >= monkeyb_X + monkeyWidth && monkeybY == 300) {
Score++;
}
fill(225,225,225);
textSize(20);
text("your score is: " + Score, 30, 30);
}
These are the images:
(url)
https://www.dropbox.com/sh/yfmfvp59xdc6n3z/AAB2LDcKUn7uApQF-OAfCf1ja?dl=0