# Why is the bullet not shooting?

**URL:** <https://discourse.processing.org/t/why-is-the-bullet-not-shooting/32613>\
**Category:** Coding Questions\
**Created:** [October 4, 2021, 6:46pm UTC](https://discourse.processing.org/t/why-is-the-bullet-not-shooting/32613 "2021-10-04T18:46:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MoonAlien822](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Post date:** [October 4, 2021, 6:46pm UTC](https://discourse.processing.org/t/why-is-the-bullet-not-shooting/32613/1 "2021-10-04T18:46:55Z")

</div>

why is the bullet not shooting/

```auto
//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;
}
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 4, 2021, 9:07pm UTC](https://discourse.processing.org/t/why-is-the-bullet-not-shooting/32613/2 "2021-10-04T21:07:10Z")

</div>

> [@MoonAlien822](#):
>
> ```auto
> if (get(width/2-92, 498)==color(0,0,0)) {
> if (bulletx==width/2-99&&bullety<490+200) {
> bulletx=charx;
> }
> }
> 
> ```

try to comment this out?

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

---

<div class="post-metadata">

**Author:** ![MoonAlien822](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Post date:** [October 4, 2021, 9:28pm UTC](https://discourse.processing.org/t/why-is-the-bullet-not-shooting/32613/3 "2021-10-04T21:28:52Z")

</div>

hi chrisir, do you know how i can upload a processing game to [itch.io](http://itch.io)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 4, 2021, 9:29pm UTC](https://discourse.processing.org/t/why-is-the-bullet-not-shooting/32613/4 "2021-10-04T21:29:40Z")

</div>

no idea

apologies

Chrisir
