0

i tried multiple ways to replace the pygame.draw.rect() in this class to different ways to make it display an image instead but it doesn't seem to work so far

first try

class Enemy():
    def __init__(self, x, y, mode, dist, walk=3):
        #mode 0 = vertical
        #mode 1 = horizontal
        self.x = x
        self.y = y
        self.walk = walk
        self.mode = mode
        self.dist = dist
        self.hp = 100
        self.counter = 0
        pygame.sprite.Sprite.__init__(self)
        self.original_image = pygame.transform.scale(pygame.image.load('enemy1.png'), (100, 120))
        self.image = self.original_image
        self.rect = self.image.get_rect(center = (x, y))


    def main(self, display):
        if self.mode == 0:
            self.y += self.walk
            self.counter += 1
            if self.counter >= self.dist:
                self.counter = 0
                self.walk *= -1
        if self.mode == 1:
            self.x += self.walk
            self.counter += 1
            if self.counter >= self.dist:
                self.counter = 0
                self.walk *= -1


        pygame.draw.rect(display, (255, 0, 0), (self.x, self.y, 16, 16), True)



this try only displayed the drawn rectangle coded for in the bottom and i don't know how to get it to be replaced by the image

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
jChang
  • 1

0 Answers0