Fire again once the cannon is moved

final int OBST_WIDTH = 100;

int targetWidth = OBST_WIDTH;
final int BARREL_LENGTH = 45;
int cloudDiam=50;  /* CHECK THIS LATER    */
int spacing = cloudDiam;
float cannonX = cloudDiam*2;
int cannonWidth = OBST_WIDTH/2;
int cloudY, rectY, OBST_HEIGHT, targetX, targetY, targetHeight;
int cannonY, cannonHeight;

float rectX, brickX, brickY;
float barrelAngle  = PI+HALF_PI+QUARTER_PI;
float lineX1, lineY1, lineX2, lineY2;
final float MOVE_SPEED = 4;
final float BARREL_SPEED = 0.05;

final int NUM_OF_ROW=20, NUM_OF_COL=4;
final int BRICK_HEIGHT = 10;
final int BRICK_WIDTH = 25;


float time=0;
float initX=lineX2;
float initY=lineY2;
float ballX;
float ballY;
float flightTime, timeFired;

float velocity=7;
float initVx;
float initVy;
float frames=60;
//float g= 9.8*1/60;
final float TIME_STEP= 0.02*frames;
float g= 0.098;
float accelX=0;
float accelY=g;
final float BALL_DIAM=12;
boolean firing=false;
boolean condition, condition2;

Upon fire copy the cannon data in the bullet

Upon leaving the screen reset the values and mark the bullet as noShow until enter is hit again

Set noShow to false when enter is hit

make noShow a variable boolean noShow = true; before setup()

Show bullet only when noShow is false

(Actually maybe the name showBullet is better; then inverse all ifs/true/false etc.; in my experience variables that say not something are confusing in the long run. Sorry for that.)

2 Likes