Answers for "pygame do you need to use int() for positions"

0

pygame do you need to use int() for positions

class Hero(pygame.sprite.Sprite):
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image = load_image('hero.png').convert_alpha()
        self.position = [0, 0]
        self.rect = self.image.get_rect()

    def update(self, dt):
        x = round(self.position[0])
        y = round(self.position[1])
        self.rect.topleft = x, y
Posted by: Guest on December-04-2020

Code answers related to "pygame do you need to use int() for positions"

Python Answers by Framework

Browse Popular Code Answers by Language