title: All the bullets are moving when I move the mouse instead of just the one being shot
body: <p>I am trying to make a basic top-down shooter game using Pygame. I just figured out how to make bullets shoot at where my mouse is, but my issue now is they will shift direction whenever I move my mouse even after being shot. Additionally, when the bullets collide with the left edge of the screen they do not disappear like with the other edges.</p>
  <p>main.py:</p>
  <pre><code>import pygame
  import time
  import math
  import os
  import sys
  import random
  from classes import *
  
  pygame.init()
  
  width, height = (1440, 900)
  win = pygame.display.set_mode((width, height), pygame.FULLSCREEN)
  pygame.display.set_caption(&quot;Dungeon&quot;)
  win.fill((255, 255, 255))
  
  # Variables to do with player shooting
  shotTimer = 0
  bullets = []
  bulletVel = 9
  
  # Initialize classes
  player = Player(50, 800, 50, 50, PLAYERSPRITE)
  
  def main():
      run = True
      FPS = 60
      clock = pygame.time.Clock()
  
  
  
      while run:
          clock.tick(FPS)
  
          now = pygame.time.get_ticks()
  
          mousex, mousey = pygame.mouse.get_pos()
  
          # Creates the player's bullets
          def shoot():
              global shotTimer
  
              if now - shotTimer &gt;= player.cooldown:
                  bullets.append(Projectile(round(player.x + player.width // 2), round(player.y + player.height // 2), 6))
                  shotTimer = now
  
          def playerBulletUpdates():
              for bullet in bullets:
                  if bullet.x &gt;= 0 and bullet.x &lt;= width:
                      if bullet.y &gt;= 0 and bullet.y &lt;= height:
                          global bulletVel
  
                          xDiff = mousex - player.x
                          yDiff = mousey - player.y
  
                          angle = math.atan2(yDiff, xDiff)
  
                          changeX = math.cos(angle) * bulletVel
                          changeY = math.sin(angle) * bulletVel
  
                          bullet.x += changeX
                          bullet.y += changeY
                      else:
                          bullets.pop(bullets.index(bullet))
  
          def bulletAngle():
              global bulletVel
  
              xDiff = mousex - player.x
              yDiff = mousey - player.y
  
              angle = math.atan2(yDiff, xDiff)
  
              changeX = int(math.cos(angle) * bulletVel)
              changeY = int(math.sin(angle) * bulletVel)
  
              bullet.x += changeX
              bullet.y += changeY
  
          def updateScreen():
              win.fill((255, 255, 255))
              player.draw(win)
  
              for bullet in bullets:
                  bullet.draw(win)
  
              playerBulletUpdates()
  
              pygame.display.update()
  
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  run = False
  
          keys = pygame.key.get_pressed()
  
          if keys[pygame.K_w] and player.y  &gt;= 0: # UP
              player.y += -player.walkSpeed
  
          if keys[pygame.K_s] and player.y + player.walkSpeed + player.height &lt;= height: # DOWN
              player.y += player.walkSpeed
  
          if keys[pygame.K_a] and player.x &gt;= 0: #LEFT
              player.x += -player.walkSpeed
  
          if keys[pygame.K_d] and player.x + player.walkSpeed + player.width &lt;= width: # RIGHT
              player.x += player.walkSpeed
  
          if pygame.mouse.get_pressed()[0]:
              shoot()
  
          updateScreen()
  
  main()
  </code></pre>
  <p>classes.py:</p>
  <pre><code>import pygame
  import math
  import os
  
  pygame.init()
  
  width, height = (1440, 900)
  win = pygame.display.set_mode((width, height), pygame.FULLSCREEN)
  
  # Import Sprites
  PLAYERSPRITE = pygame.image.load(os.path.join(&quot;assets&quot;, &quot;gunner_class.png&quot;))
  BULLETSPRITE = pygame.image.load(os.path.join(&quot;assets&quot;, &quot;bullet.png&quot;))
  
  class Player:
      def __init__(self, x, y, width, height, img):
          self.x = x
          self.y = y
          self.width = width
          self.height = height
          self.img = img
          self.walkSpeed = 5
          self.cooldown = 100
  
      def draw(self, window):
          window.blit(PLAYERSPRITE, (self.x, self.y))
  
  class Projectile:
      def __init__(self, x, y, radius):
          self.x = x
          self.y = y
          self.radius = radius
  
      def draw(self, window):
              # pygame.draw.circle(window, self.color, (self.x, self.y), self.radius)
              window.blit(BULLETSPRITE, (self.x, self.y))
  </code></pre>