In the code below I add a center and before it a top and a left attribute to the self.rect (this is only for learning and understanding pygame behavior). When I add the top attribute it seems that the top will be overwritten by the center, but having a left before center comes changes the x position of the block. Can any one explain why the left doesn't get overwritten by center?
import pygame
pygame.init()
screen=pygame.display.set_mode((500,500))
class Block(pygame.sprite.Sprite):
def __init__(self):
super(Block, self).__init__()
self.image=pygame.Surface((50,50))
self.image.fill((0,0,200))
self.rect=self.image.get_rect(top=400,center=(0,0))
#this will obviously be overwritten by center, but not the following, why?
#self.rect=self.image.get_rect(left=400,center=(0,0))
b=Block()
blockGrp=pygame.sprite.Group()
blockGrp.add(b)
print blockGrp
while 1:
pygame.time.wait(50)
for e in pygame.event.get():
if e.type==pygame.QUIT:
pygame.quit()
blockGrp.draw(screen)
pygame.display.flip()