view lib/util.py @ 59:6b9f9dcfabf1 default tip

Monster cleanup
author Radomir Dopieralski <moindev@sheep.art.pl>
date Wed, 02 Jan 2008 03:54:40 +0100
parents 2a0fdca2802b
children
line wrap: on
line source

import pygame
from pygame.locals import *

delta_x = (0, 0, 1, 0, -1)
delta_y = (0, -1, 0, 1, 0)
facings = {
    'stand':    0,
    'north':    1,
    'east':     2,
    'south':    3,
    'west':     4,
}

def read_frames(filename, size=24):
    '''Read an image and split it into tiles.'''

    image = pygame.image.load(filename).convert()
    w, h = image.get_size()
    frames = []
    for x in range(0, w/size):
        frames.append([])
        for y in range(0, h/size):
            frames[x].append(image.subsurface((x*size, y*size, size, size)))
    return frames