Mercurial > mhrok3
changeset 0:9ab6ba928336
initial commit
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Thu, 25 Oct 2012 15:53:18 +0200 |
| parents | |
| children | d61dce5a1e75 |
| files | animation.py mhrok.css mhrok.html mhrok.js whitey-scissors-stab.png whitey-scissors.png whitey.png |
| diffstat | 5 files changed, 41 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/animation.py Thu Oct 25 15:53:18 2012 +0200 @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import pygame + + +def load_tiles(filename, width=48, height=48): + #f = StringIO.StringIO(pkgutil.get_data('mhrok', filename)) + f = open(filename) + image = pygame.image.load(f, filename).convert() + image_width, image_height = image.get_size() + tiles = [] + for y in range(image_height/height): + tileset = [] + tiles.append(tileset) + for x in range(image_width/width): + rect = (x * width, y * height, width, height) + tileset.append(image.subsurface(rect)) + return tiles + + + +pygame.display.init() +screen = pygame.display.set_mode((320, 200)) +frames = load_tiles('whitey-scissors-stab.png') +clock = pygame.time.Clock() + +while True: + for x, frameset in enumerate(frames): + screen.fill((0x66, 0x66, 0x66)) + for y, frame in enumerate(frameset): + screen.blit(frame, (0, y * 48)) + pygame.display.flip() + clock.tick(6) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + raise SystemExit()
