Unless you explicitly copy the image or build it multiple times, there's no copying "behind the scenes". They'll all point to the same image. -FM Chris wrote: > Jake, > > The image loads here... > > def game_image (image_file): > image = pygame.image.load (image_file).convert_alpha () > return image > > The image is assigned like... > > red_stone = game_image ("red_stone.png") > > Later, it goes into the list like... > > board_layout.append ([red_stone, (x, y)...]) > > So is a copy of red_stone in the list or just a pointer? > > > Jake b wrote: >>> When an element of the list says <Surface 50x50x32>, is that pointing >>> to a >>> spot in the memory or is the actual image being stored in that index? >> That's a surface. You can have multiple variables point to the same >> surface. >> >>> Would I have 64 images in my list if every space is occupied or would >>> I have just >>> 2 images in memory? >> I can't be sure without seeing your init/draw code, but it sounds like >> you probably have 64. >> >> Are you doing something like this? >> >> def init(): >> """game init""" >> red = pygame.Surface( [10, 10] ) >> red.fill( pygame.color.Color( "red" ) ) >> blue = pygame.Surface( [10, 10] ) >> blue.fill( pygame.color.Color( "blue" ) ) >> # init tiles with color red >> for tile in tile_list: >> # sharing one surface for tiles >> tile.image = red >> >> def draw(): >> """game draw""" >> for tile in tile_list: >> # draw using tile.image >
Attachment:
signature.asc
Description: OpenPGP digital signature