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

[pygame] Best way to access data



Hi everybody,

I had a question as to which way would be better to access data after
loading it into memory.

The code looks like this now:
   In the main loop file, I cache the images into dictionaries:
         images_list = ["enemy.png","player.png"]
         global cache
         cache = cacheimages.cache_images(images_list)

  then in the enemy or player files, I access the images like this:
        import play
        self.rect = play.cache["enemy.png"].get_rect()  # I refer to
the file play and read cache                           from there

Is it better to read from another file like that? Would there be
another way to do it that might be better?

Thanks,
spot.