0

while wrtiing chess engine , i am using blit for drawing the pieces on the board. the problem is that it looks very bad , a black rectangle is created and added to the icons of the pieces . it looks like that:

http://i58.tinypic.com/n1fbzc.jpg

but i want it to look like this:

http://i62.tinypic.com/4zutfo.jpg

here is the code, the first 2 lines is example for one piece, and the rest(the "for") is for drawing all of them:

    white_queen = pygame.image.load(os.path.join("images","wQn.png")).convert()
    self.icons['wQ'] = pygame.transform.scale(white_queen, (self.square_size,self.square_size))

    for r in range(boardSize):
        for c in range(boardSize):
            print "r is " + str(r) + ", and c is " + str(c)
            (screenX,screenY) = self.ConvertToScreenCoords((r,c))
            piece_name = board[r][c]
            print "screen x is " + str(screenX) + ", and y is " + str(screenY)
            print "name is " + piece_name
            if piece_name != 'e':
                self.screen.blit(self.icons[piece_name],(screenX,screenY), special_flags = BLEND_RGBA_MULT)

    pygame.display.flip()

i guess that i am missing some parameter in calling to blit , or to call another function..

tahnks for your help.

  • 1
    This is a problem with your images. Go edit each one of them, converting all the unwanted area into a transparent area and then run your code. – sshashank124 May 05 '14 at 12:24
  • Why are you using: `special_flags = BLEND_RGBA_MULT`? Also, I recommend you to use `pygame.transform.smoothscale()` instead of `scale()`. – pmoleri May 05 '14 at 12:46
  • there is no problem in the images , they are all transparent in the all unwanted area. – user3604147 May 05 '14 at 15:54
  • and - i am using this flag because its gives the best result in comparison to other options.. – user3604147 May 05 '14 at 15:56
  • I suspect @sshashank124 is correct, and you might be confused because the background appears entirely black in whatever program you are using to view them with. Make sure the program you using differentiates between a black background and transparency. – KSab May 08 '14 at 05:35

0 Answers0