python - How to use sides of a sprite rect in pygame? -




i attempting draw line between 2 different instances of same sprite class, sprite class being coded in shown here (this __init__ function):

class atom(pygame.sprite.sprite): """creates atom of element.  element can specified using element parameter.  take dict argument, contained in constants file of sort.""" def __init__(self, element, centre_loc):     pygame.sprite.sprite.__init__(self)      self.image = pygame.surface((30, 30), pygame.srcalpha)     pygame.gfxdraw.aacircle(self.image, 15, 15, 14, (0, 255, 0))     pygame.gfxdraw.filled_circle(self.image, 15, 15, 14, (0, 255, 0))       self.rect = self.image.get_rect()     self.rect.center = centre_loc     self.element = element     self.show_text(element)     self.print_properties(self.element) 

i have tried using code here:

pygame.draw.line(screen, color, sprite.rect.right. sprite.rect.left) 

i have simplified above code, highlight have done. actual code above found here, commented out on line 25. rest of code can found in repository reference.

i had hoped work got error instead:

typeerror: invalid start point argument

so doing wrong here? in advance.

sprite.rect.left , sprite.rect.right , not valid points because each single integer. want sprite.rect.topleft , sprite.rect.topright, or bottom or mid equivalents.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -