summaryrefslogtreecommitdiff
path: root/common.py
blob: 7ccf8e931c0aa08e29a6160ccd32fc04157227ab (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os

class Squares(object):
    EMPTY = '.'
    APPLE = '*'

class Sprites(object):
    PREFIX = 'images'
    def __getattribute__(self, name):
        try:
            return object.__getattribute__(self, name.upper())
        except AttributeError:
            from pygame.image import load
            filename = os.path.join(self.PREFIX, name.lower() + ".png")
            image = load(filename).convert_alpha()
            setattr(self, name, image)
            return image
Sprites = Sprites()