[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Storing images in a list



> 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
-- 
Jake