Sign in to follow this  
Zaku

how to animate in python?

Recommended Posts

i now know how to import python, i know how to add a backgrounds and visual objects, but how do i make them move? i read a bunch of python game guides, and i still cant figure it out. can someone help me out here?

Share this post


Link to post
Share on other sites
def load_image(name, colorkey=None):
fullname = os.path.join('data', name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print 'Cannot load image:', name
raise SystemExit, message
image = image.convert()
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0,0))
image.set_colorkey(colorkey, RLEACCEL)
return image, image.get_rect()

wait, when it says "name", does it mean file name of the sprite, like "chimp.bmp"?

[Edited by - Fruny on October 10, 2006 3:16:05 PM]

Share this post


Link to post
Share on other sites
Quote:
wait, when it says "name", does it mean file name of the sprite, like "chimp.bmp"?


Yes. os.path.join will prepend "data/" so that if you tell it "chimp.bmp", it'll try to load "data/chimp.bmp".

And when posting a chunk of python code, you should either bracket it with [code][/code] or [source lang="python"][/source], so as to preserve indentation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this