title: Unable to use pygame.PixelArray properly
body: <p>I'm trying to make a per-pixel 2D lighting system, but I keep getting a weird error. Here's my code with explanations along the way:</p>
  
  <pre><code>import pygame, sys, math
  
  white = (255, 255, 255)
  black = (0, 0, 0)
  
  screen_width = 640
  screen_height = 480
  
  pygame.init()
  pygame.display.set_caption("Light sources")
  screen = pygame.display.set_mode([screen_width, screen_height])
  clock = pygame.time.Clock()
  </code></pre>
  
  <p>These are the regular setup lines for any pygame game</p>
  
  <pre><code>darkness = pygame.image.load("grafiikka/pimeys.png")
  darkness.set_alpha(254)
  
  lights_list = [] ### For controlling all light sources at a time
  </code></pre>
  
  <p>Loading in a one-colored darkness image. This will be blit on top of everything else to make it dark. I would then simulate light by changing the alpha value of the darkness in the light area.</p>
  
  <pre><code>class lightsource: ### The parameters for a light
      def ___init___(self, loc, ang, direction, radius):
          self.loc = loc
          self.ang = ang
          self.dir = direction
          self.radius = radius
  </code></pre>
  
  <p>I make the lightsource class</p>
  
  <pre><code>def LightDraw(): ### Drawing the lights, pixel per pixel
      for v in lights_list:
          for i in range (int((v.dir - v.ang/2)), int((v.dir + v.ang/2))):
              for l in range (0, v.radius):
                  if int(i) &lt; 90 and int(i) &gt;= 0:
                      x = (v.loc[0]) + int(-l * math.cos(math.radians(i)))
                      y = (v.loc[1]) + int(-l * math.sin(math.radians(i)))
                  elif i &lt; 180 and i &gt;= 90:
                      x = (v.loc[0]) + int(l * math.cos(math.pi - math.radians(i)))
                      y = (v.loc[1]) + int(-l * math.sin(math.pi - math.radians(i)))
                  elif i &lt; 270 and i &gt;= 180:
                      x = (v.loc[0]) + int(l * math.sin(1.5 * math.pi - math.radians(i)))
                      y = (v.loc[1]) + int(l * math.cos(1.5 * math.pi - math.radians(i)))
                  elif i &lt; 360 and i &gt;= 270:
                      x = (v.loc[0]) + int(-l * math.cos(2 * math.pi - math.radians(i)))
                      y = (v.loc[1]) + int(l * math.sin(2 * math.pi - math.radians(i)))
                  alpha = int(254 * (l / v.radius))
                  print(int(254 * (l / v.radius)))
                  pygame.TempPimeys[x, y] = pygame.Color.a(alpha) ### THIS CAUSES ERROR
  
      return TempPimeys.make_surface()
  
  ### Adding a test light source at (300, 200) on screen    
  testValo = lightsource()
  testValo.___init___((300,200), 360, 90, 100)
  lights_list.append(testValo)
  </code></pre>
  
  <p><strong>The error is in the function</strong>, namely in the line where I'm actually changing the alpha value. I don't understand what the heck is causing the error.</p>
  
  <pre><code>while True:
  
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              pygame.quit()
              sys.exit()
  
      myOtherImage_rect.topleft = pygame.mouse.get_pos()
  
      screen.fill(white)
      TempPimeys = pygame.PixelArray(pimeys)
      hämärä = LightDraw()
      screen.unlock()
      screen.blit(hämärä, (0, 0))
      pygame.display.update()
  </code></pre>
  
  <p>And the general loop.</p>
  
  <p>The error I'm getting is: TypeError: 'getset_descriptor' object is not callable</p>