What I am doing is creating a memory Tile game that requires a list of 8 images to appear at once twice each. This is the portion of my code that is have issues.
self.images_1_2_8 = ['image1.bmp','image2.bmp','image3.bmp','image4.bmp','image5.bmp','image6.bmp','image8.bmp','image7.bmp','image1.bmp','image2.bmp','image3.bmp','image4.bmp','image5.bmp','image6.bmp','image7.bmp','image8.bmp']
self.collect_images = []
for select_images in self.images_1_2_8:
image = pygame.image.load(select_images)
#width = image.get_width()
#height = image.get_height()
random.shuffle(self.self.images_1_2_8)
for row_index in range(0, self.board_size):
row = []
for col_index in range(0,self.board_size):
width = image.get_width()
height = image.get_height()
x = width * col_index
y = height * row_index
tile = Tile(x,y, self.select_images_1_2_8[image_index], self.surface) row.append(tile)
self.board.append(row)
The error message that I keep getting is: builtins.TypeError: 'pygame.Surface' object is not subscriptable
I found out that this means that the getitem() property isn't reading my images as a list? I think that's what it means. The images appear (only one image from the list, which fills all 16 indexes) if I remove the list [row_index*self.board_size+col_index].
I know it's an easy fix but I'm brand new to python and I've been at this for weeks now... Thank you in advance if anyone is able to help!
image[]
? The error makes it sound like it's a single image, not a list. – Kingsley Dec 3 at 1:40