1

I am trying to make a simple game(PONG) but I get an error when I run it. My code:

class Player1(pygame.sprite.Sprite):    
    def __int__(self):
        pygame.sprite.Sprite.__int__(self)
        self.image = pygame.Surface((10, 80))
        self.image.fill(color_white)
        self.rect = self.image.get_rect()
        self.rect.left = 25 
        self.rect.centery = window_height 
        player1 = Player1()
        game_window = pygame.display.set_mode((window_width,window_height))
        all_sprites.draw(game_window)

I get an error but for pygame itself:

self.spritedict[spr] = surface_blit(spr.image, spr.rect)
AttributeError: 'Player1' object has no attribute 'image'

This is the line which is probably causing the 'object' does not have attribute 'image' error:

self.spritedict[spr] = surface_blit(spr.image, spr.rect)
John Anderson
  • 35,991
  • 4
  • 13
  • 36
  • 2
    You appear to have named your initializer method `__int__` rather than `__init__`, so it's probably not running when you expect. – Blckknght Dec 10 '18 at 17:39

0 Answers0