[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Best way to access data
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Best way to access data
- From: "spotter ." <talonspotter@xxxxxxxxx>
- Date: Tue, 11 Jul 2006 10:56:29 -0400
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Tue, 11 Jul 2006 10:56:39 -0400
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=UqozPuOEFSVhGSDDJJC92zaJj01O94sUbQHZiqcSMsJyW+wl80iqtJ/XcyGCzNhZEkbqU2978deuKu1S9n5GfVIZVXgCxHmTVaHS5YGwOVojc/kQY/Fl6iIQIVZX3KxsymYeX7sh0bRFtgSoffVt1C4HUFJiD7CaCdBQXqIPY50=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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.