Need some home help combining both of these

I’m trying make the player shoot the bullets, but I have no idea how. What I do know that is that the second code can make player shoot bullets. I just need help making them fit each other.

[code re-posted below]

Hey,

First of all, there’s a lot of code, try to be as clear as possible and format your code using the </> button in the message editor and press Ctrl+T in the Processing IDE code editor.

Hey!

Thanks for telling me how to do the auto format!

I incorporated both, but all I need to do is make the player shoot the bullets.

player player;

ArrayList<Bullet> bullets;
//Vars to regulate shooting speed
boolean canShoot = true;
float canShootCounter;

int i;

PImage Title;
PImage Press;
PImage TutorialImage;
PImage Matthew;

float presstint= 255;

float screen =1; 

void settings() {
  size(1024, 768);
  player = new player(400, 400, 5, 50);
  bullets = new ArrayList<Bullet>(); 

  Title=loadImage("Title.png");
  Press=loadImage("press.png");
  TutorialImage= loadImage("tutorial.png");
  Matthew= loadImage("matthew.png");
}

void draw() {
  background(0);


  smooth();
  println("mouse is at", mouseX, mouseY);
  println("frames are at", frameRate);
  smooth();
  frameRate(60);

  if (screen ==1) {
    tint(255);
    image(Title, 0, 0);

    tint(presstint);
    image(Press, 0, 0);
    presstint= presstint -4;
    if (presstint < 0) {
      presstint = 255;
    }

    if ((mousePressed == true) || (keyPressed == true)) {
      screen =2;
    }
  } else if (screen ==2) {

    noTint();
    image(TutorialImage, 0, 0);
    player.update();
    for (i = bullets.size()-1; i >= 0; i--) {
      //you need a seperate var to get the object from the bullets arraylist then use that variable to call the functions
      Bullet bullet = bullets.get(i);
      bullet.update();
    }

    if ((playerx == 920) && (playery == 361)) {
      screen =3;
    }
  }
}
void keyPressed() {
  player.keyp();
}

void keyReleased() {
  player.keyr();
}

class player {
  PVector location;
  int playerx, playery, spd, size;
  boolean[] keys=new boolean[5];
  player(int playerx1, int playery1, int spd1, int size1) {
    playerx=playerx1;
    playery=playery1;
    spd=spd1;
    size=size1;
    location = new PVector(100, 100);
  }


  void update() {
    if (keys[1]==true) {
      playery=playery-spd; 
      {
        if (playery<= 88) {
          playery = 88;
        }
      }
    }
    if (keys[2]==true) {
      playerx=playerx-spd;
      {
        if (playerx<= 110) {  
          playerx = 110;
        }
      }
    }
    if (keys[3]==true) {
      playery=playery+spd;
      {
        if (playery >= 551) {
          playery = 551;
        }
      }
    }
    if (keys[4]==true) {
      playerx=playerx+spd; 
      {
        if (playerx >= 829) {
          playerx = 829;
        }
      }
    }
    image(Matthew, playerx, playery, 49, 66);
    println("spd", spd);
    if (mousePressed == true) {
      // this regulates the shooting speed
      if (canShoot == true) {
        bullets.add( new Bullet());
        canShoot = false;
        canShootCounter = 0;
      }
    }
    // this checks if the right amount of time has passed before canShoot can = true again
    if (canShoot == false) {
      canShootCounter ++;
      //if the right amount of time has passed. make canShoot true
      if (canShootCounter == 5)/*change this number to change the duration*/ {
        canShoot = true;
      }
    }
  }

  void keyp() {
    if (key=='w') {
      keys[1]=true;
    }
    if (key=='a') {
      keys[2]=true;
    }
    if (key=='s') {
      keys[3]=true;
    }
    if (key=='d') {
      keys[4]=true;
    }
  }
  void keyr() {
    if (key=='w') {
      keys[1]=false;
    }
    if (key=='a') {
      keys[2]=false;
    }
    if (key=='s') {
      keys[3]=false;
    }
    if (key=='d') {
      keys[4]=false;
    }
  }
}

class Bullet {
  //standard PVector used for the location of the bullet
  PVector location;
  //vars used to check the angle between location and the mouse
  float oldPosX, oldPosY, rotation, speed;
  Bullet() {
    //places the bullet in the middle of the room
    location= new PVector(width/2, height/2);
    //this checks the angle
    oldPosX = mouseX;
    oldPosY = mouseY;
    rotation = atan2(oldPosY - location.y, oldPosX - location.x) / PI * 180;
    //bullet speed
    speed = 10;//change this number to change the speed
  } 
  void update() {
    //move the bullet
    location.x = location.x + cos(rotation/180*PI)*speed;
    location.y = location.y + sin(rotation/180*PI)*speed;
    ellipse(location.x, location.y, 10, 10);

    //removes the bullet from the arrayList if it is off the room
    if (location.x > 0 && location.x < width && location.y > 0 && location.x < height) {
    } else {
      bullets.remove(i);
    }
  }
}

Hey,

What I don’t understand is where does the second part of the code comes from? Did you implement it?
What don’t you understand when it comes to shoot a bullet?