why can I not shoot when the screen is inverted?
//visual
PImage shrek;
boolean invert= false;
boolean shooting;
PImage[] soldier= new PImage[3];
PImage crosseye;
PImage nocrosseye;
PImage eyebot;
PImage heart;
//timer
//moving
boolean enemy1life= true;
float charx;
float chary=590-100;
boolean jumping= false;
float gravity= 10;
float jumpingheight=100;
float jumpspeed;
int i=1;
float bulletx;
float bullety;
float enemyx=0;
void setup() {
size(1180, 590);
charx=width/2;
bulletx=charx+20;
bullety=chary+20;
shrek= loadImage("shrek.jpg");
soldier[1]= loadImage("soldier.png");
soldier[2]= loadImage("revsoldier.png");
eyebot= loadImage("eyebot.png");
}
void draw() {
frameRate(60);
//visual
background(shrek);
color(1005);
fill(255);
rect(width/2+100, 490, 20, 200);
fill(0);
rect(width/2-100, 490, 20, 200);
ellipse(bulletx, bullety, 10, 10);
image(soldier[i], charx, chary, 100, 100);
if(enemy1life==true){
image(eyebot, enemyx, 490-40, 100, 200);}
//timer
if (millis()/1000%15==0&&millis()/1000>10&& invert==false) {
invert=true;
}
if (millis()/1000%30==0&&millis()/1000>10&& invert==true) {
invert=false;
}
if (invert==true) {
filter(INVERT);
}
//moving
if(charx-enemyx>=0&&charx != enemyx){
enemyx= enemyx+5;
}
if(charx-enemyx<0&&charx != enemyx){
enemyx= enemyx-5;
}
if (charx>=width-100) {
charx=width-100;
}
jumpspeed= int(dist(0, jumpingheight, 0, chary)/20);
if (chary>height-100) {
chary=height-100;
}
if (keyPressed) {
//move left with a
if (key == 'a'&&invert==false) {
charx=charx-10;
i=2;
}
//move right with d
if (key == 'd'&&invert==false) {
charx=charx+10;
i=1;
}
//move right with a
if (key == 'a'&&invert==true) {
charx=charx+10;
i=1;
}
//move left with d
if (key == 'd'&&invert==true) {
charx=charx-10;
i=2;
}
//jump with w
if (key == 'w') {
jumping=true;
}
//shoot with space
if (key == ' ') {
shooting=true;
}
}
if (charx<=0) {
charx= 0;
}
if (jumping==true) {
chary=int(chary-jumpspeed);
charx=charx+0.1;
if (jumpspeed<10&&chary<height-30) {
jumping=false;
}
}
if (chary!=height-100&&jumping==false) {
chary+=gravity;
}
if(shooting==true&&i==1&&bulletx>=charx+20&&invert==false){
bulletx+=10;
}
if(shooting==true&&i==2&&bulletx<=charx+20&&invert==false){
bulletx=bulletx-10;
}
if(shooting==true&&i==1&&bulletx>=charx+20&&invert==false){
bulletx+=10;
}
if(shooting==true&&i==2&&bulletx<=charx+20&&invert==false){
bulletx=bulletx-10;
}
if(bulletx>width){
shooting=false;
}
if(shooting==false){
bulletx=charx+20;
}
println(charx);
if(invert==true){
if(charx==620){
charx=610;
}
}
if(invert==false){
if(charx==480){
charx=charx+10;
}
}
if(invert==true){
if(bulletx==620){
bulletx=charx+20;
shooting=false;
}
}
if(invert==false){
if(bulletx==480){
bulletx=charx+20;
shooting=false;
}
}
if(invert==true){
if(enemyx==width/2+60){
enemyx=enemyx+20;
}
}
if(invert==false){
if(enemyx==width/2-10-150){
enemyx=enemyx-20;
}
}
if(bulletx==enemyx){
enemy1life=false;
}
if(shooting==false){
bulletx=charx+20;
}
}