Chris wrote:
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?
That particular question can be answered based on the
principles of
Thank you, Jake and Charlie. I appreciate your responses. I don't
think I have to change anything. The concern was storing explicit
copies in the list versus pointing. All clear now. Storing 360
elements of red stone is the same as 5 so long as I load it only once.
That's what I hoped and
Like Charlie said: as long as you make sure you only have one call per
unique filename, then you will not have copies.
But you can make it easier on yourself, by writing a basic
texture/surface manager so that repeated calls only load the surface
once.
( If you don't want to use an id, you can re
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 ()
>
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
> When an element of the list says , 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
I'm doing a board game on an 8 by 8 grid.
I have two colors of units--red and blue.
My question is this:
When an element of the list says , is that pointing to
a spot in the memory or is the actual image being stored in that index?
Would I have 64 images in my list if every space is occupied