Why is the bullet not shooting?

why is the bullet not shooting/

//visual
PImage shrek;
boolean invert= false;
boolean shooting;
PImage[] soldier= new PImage[3];

PImage crosseye;
PImage nocrosseye;
PImage eyebot;
PImage heart;

//timer

//moving
float charx;
float chary=590-100;
boolean jumping= false;
float gravity= 10;
float jumpingheight=100;
float jumpspeed;
int i=1;
float bulletx;
float bullety;

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");
  nocrosseye= loadImage("nocrosseye.png");
  eyebot= loadImage("eyebot.png");
  heart= loadImage("heart.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);

  //timer
  println(millis()/1000);
  if (millis()/1000%300==0&&millis()/1000>10&& invert==false) {
    invert=true;
  }
  if (millis()/1000%600==0&&millis()/1000>10&& invert==true) {
    invert=false;
  }
  if (invert==true) {
    filter(INVERT);
  }


  //moving
  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 (get(width/2+108, 498)==color(0,0,0)) {
    if (bulletx==width/2+99&&bullety<490+200) {
      bulletx=charx;
    }
  }
      if (get(width/2-92, 498)==color(0,0,0)) {
    if (bulletx==width/2-99&&bullety<490+200) {
      bulletx=charx;
    }
  }
  if (shooting==true&&i==1) {
    bulletx++;
  }
    if (shooting==true&&i==2) {
    bulletx--;
  }
  if(shooting==false){
    bulletx=charx+30;
}
}

try to comment this out?

  • make a proper debug, use println() to test whether parts of the code are reached

hi chrisir, do you know how i can upload a processing game to itch.io

no idea

apologies

Chrisir