• Advertisement
Sign in to follow this  

how to animate in python?

This topic is 4118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Are you using PyGame? If so, it's just a matter of modifying your game loop to change the X and Y positions of where you're drawing your sprite.

Share this post


Link to post
Share on other sites
hooray, the forum is up!

neway, im using pygame. can i get an example just to get me going?

thanks!

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
Sign in to follow this  

  • Advertisement