title: How to rotate an object by changing it's point coordinates (Python, Pygame)
body: <p>I've been working on a basic game using Pygame in Python, but I can't for the life of me figure out a formula to rotate a shape by changing it's base coordinates. Here's what I have so far: </p>
  
  <pre><code>pygame.init()
  screen = pygame.display.set_mode(size)
  pygame.display.set_caption("Singleplayer Mode")
  done = False
  clock = pygame.time.Clock()
  
  p11 = 100
  p12 = 100
  p21 = 100 
  p22 = 150
  p31 = 150
  p32 = 125
  
  upspeed = 0
  rightspeed = 0
  topspeed = 25
  
  pause = "false"
  
  while not done:
      screen.fill(WHITE)        
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              done = True
          elif event.type == pygame.KEYDOWN:
              if event.key == K_w:
                  upspeed -= 1
              if event.key == K_s:
                  upspeed += 1
              if event.key == K_d:
                  rightspeed += 1
              if event.key == K_a:
                  rightspeed -= 1
              if event.key == K_SPACE:
                  pass
              if pause == "true":
                  if event.key == K_p:
                      pause = "false"
                      print("Game is unpaused.")
                  if event.key == K_q:
                      done = True
              if event.key == K_p:
                  pause = "true"
                  print("Game is paused.")
  
      if rightspeed &gt; 0:
          rightspeed -= 0.01
      if rightspeed &lt; 0:
          rightspeed += 0.01
      if upspeed &gt; 0:
          upspeed -= 0.01
      if upspeed &lt; 0:
          upspeed += 0.01
  
      if pause != "true":
          p11 += rightspeed
          p21 += rightspeed
          p31 += rightspeed
          p12 += upspeed
          p22 += upspeed
          p32 += upspeed
  
      if p12 &lt; 0:
          upspeed = 0
      if p11 &lt; 0:
          rightspeed = 0
      if p31 &gt; w:
          rightspeed = 0
      if p22 &gt; h:
          upspeed = 0
  
      pygame.draw.polygon(screen, BLACK, [[p11, p12], [p21, p22], [p31, p32]], 0)
  
      pygame.display.flip()
      clock.tick(60)
  
  pygame.quit()
  </code></pre>
  
  <p>Essentially what I want to do is take that triangle that I create, and rotate it instead of making it move right or left when I press the d and a keys. Is there any formula I could use to change the values of p11,p12,p21,p22,p31, and p32 to accomplish this? </p>