blob: 50b8eb0216b3ce04c84bb0d6c0b108819f13831b (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import os
directions = {
'U': (0, -1),
'D': (0, 1),
'L': (-1, 0),
'R': (1, 0),
}
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()
|