title: Python - Pygame bullet movements
body: <p>I am trying to find a way to get the rotation of the ship and apply it to the beam so that it will travel in the direction it was shot in.. I really have no idea how I would do this but here is my code: Please excuse the messiness of it, I put comments in so you know whats what.</p>
  
  <pre><code>import sys, pygame, math, time;
  from pygame.locals import *;
  spaceship = ('spaceship.png')
  mouse_c = ('crosshair.png')
  backg = ('background.jpg')
  fire_beam = ('beams.png')
  pygame.init()
  screen = pygame.display.set_mode((800, 600))
  bk = pygame.image.load(backg).convert_alpha()
  mousec = pygame.image.load(mouse_c).convert_alpha()
  space_ship = pygame.image.load(spaceship).convert_alpha()
  f_beam = pygame.image.load(fire_beam).convert_alpha()
  f_beam = pygame.transform.scale(f_beam, (50, 50))
  f_beam_rect = f_beam.get_rect()
  clock = pygame.time.Clock()
  pygame.mouse.set_visible(False)
  space_ship_rect = space_ship.get_rect()
  space_ship_rect.centerx = 375
  space_ship_rect.centery = 300
  speed = 3.5
  pressed_down = 0
  while True:
      clock.tick(60)
      screen.blit(bk, (0, 0))
      for event in pygame.event.get():
          if event.type == QUIT:
              pygame.quit()
              sys.exit()
          elif event.type == MOUSEBUTTONDOWN and event.button == 3:
              pressed_down = 1
          elif event.type == MOUSEBUTTONUP:
              pressed_down = 0
          if pressed_down == 1:
              x, y = pygame.mouse.get_pos()
              x1, y1 = x - space_ship_rect.x, y - space_ship_rect.y
              angle = math.atan2(y1, x1)
              dx = speed*math.cos(angle)
              dy = speed*math.sin(angle)
              movex = space_ship_rect.centerx = space_ship_rect.centerx + dx#ship x
              movey = space_ship_rect.centery = space_ship_rect.centery + dy#ship y
          if event.type == MOUSEMOTION:
              x1, y1 = pygame.mouse.get_pos()
              x2, y2 = space_ship_rect.x, space_ship_rect.y
              dx, dy = x2 - x1, y2 - y1
              rads = math.atan2(dx, dy)
              degs = math.degrees(rads)
              display_s = pygame.transform.rotate(space_ship, (degs))#rotation of ship
          if event.type == MOUSEBUTTONDOWN and event.button == 1:
              #Is it possible for me to get the degree rotation of the space_ship and apply it to here so the beam will travel in the direction it was shot in?
      screen.blit(display_s, (space_ship_rect.centerx, space_ship_rect.centery))
      pos = pygame.mouse.get_pos()
      screen.blit(mousec, (pos))
      pygame.display.update()
  </code></pre>