I don’t know what I’m doing wrong and I don’t understand processing that well; Can Someone help me fix the issues and bugs in my program
[details=“Summary”]
This text will be hidden
//plane coordinates
int planeX = 50, planeY = 50;//plane initaial position
int planeWidth = 60, planeHeight = 20;//plane size
int cockpitX = planeX + 60, cockpitY = 60;//cockpit position of the plane
int cockpitWidth = 45, cockpitHeight = planeHeight;// size of the cockpit
int wingX1 = planeX, wingX2 = planeX + 30, wingY1 = 30, wingY2 = 70;//wing position and size
//position of the food;
int x = planeX;
int y = planeY ;
boolean onlyOneDrops = true; //so another package doesn’t drop
boolean foodReleased = true;
void setup()
size(500, 500);
void draw()
background(#C5D7FA);//blue
drawBackground();
movePlane();
drawPlane();
dropFood();
if (keyCode == ENTER)
textSize(30);
fill(0);
text(“FOOD RELEASED”, width0.25, height0.4);
else
foodReleased = !foodReleased;
target();
void drawBackground() {
final float HORIZON_Y = height * 0.9;//height of the horizon
final float HORIZON_X = width;//end of the horizon
noStroke();
fill(#2C673D);//forest green
rect(0, HORIZON_Y, HORIZON_X, height);//horizon
treeLocation(0, height0.8, height0.9, 25);
void treeLocation(float treeX, float treePostY, float treeY, final float TREE_SIZE)
final float SPACING= 30;
for (int i=0; i<=width; i++)
treeX = SPACING * i;
treeX+= SPACING/5;
stroke(#6C482C);//brown
strokeWeight(4);
line(treeX, treePostY, treeX, treeY);
noStroke();
fill(#35C958);//light green
circle(treeX, treePostY, TREE_SIZE);
void drawPlane()
noStroke();
fill(#7275FA);
rect(planeX, planeY, planeWidth, planeHeight);
ellipse(cockpitX, cockpitY, cockpitWidth, cockpitHeight);
triangle(wingX1, wingY2, wingX1, wingY1, wingX2, wingY2);
void movePlane()
final float SPEED = 2.0;
planeX+=SPEED;
cockpitX+=SPEED;
wingX1+=SPEED;
wingX2+=SPEED;
if (planeX>width && cockpitX>width+20 && wingX1>width && wingX2>width && wingX2>width)
planeX = -20;
cockpitX = 40;
wingX1 = -20;
wingX2 = -20;
wingX2 = 20;
float calcTimeSinceDropped(float time)
time = ENTER;
return time;
float calcFoodX(float flightTime, float initX, float initV)
initX = initX + initV * flightTime;
x += initX;
return x;
float calcFoodY(float flightTime, float initY)
final float GRAVITY = 0.25;//gravity to move the food
initY = initY + 0.5 * GRAVITY * (flightTime*flightTime);
y += initY;
return y;
void dropFood() {
if (keyCode==ENTER && onlyOneDrops)
x += calcFoodX(0, 0, 0);
y += calcFoodY(0, 0);
final int FOOD_SIZE = 10;
strokeWeight(1);
stroke(0);
fill(#FF05AC);
rect (x, y, FOOD_SIZE, FOOD_SIZE);
fill(#F01657);
textSize(18);
text(“FoodX:”+" “+ (int)x, width * 0.02, height * 0.1);
text(“FoodY:”+” "+ (int)y, width* 0.02, height* 0.14);
boolean foodInObject(float objectX, float objectY, float objectDiameter, float foodX, float foodY)
int score = 0;
if (foodX == objectX || foodY == objectY )
score++;
text(“shots”+" " + score, width4/5, height1/5);
text(“TARGET HIT”, width/2, height/2);
return true;
else
score = 0;
text(“MISS!”, width/2, height/2);
return false;
boolean belowGround(float y)
if (y>height)
return true;
else
return false;
boolean outOfView(float x)
if ( x>width)
return true;
else
return false;
void target()
float circleX = 300;
float circleY = height * 0.95;
float targetSize = 40;
strokeWeight(1);
stroke(0);
fill(#CB792B);
circle( circleX, circleY, targetSize);