Littluns

Littluns Commit Details

Date:2011-12-05 18:57:42 (1 year 5 months ago)
Author:Ciaran Gultnieks
Branch:master
Commit:28573196577fd653cf66b775d953158bafabebfe
Parents: 5c49527940f303660179c0ef8092824ea3647ae0
Message:Do the card pictures properly in the memory game

Changes:
Mmemory.py (2 diffs)

File differences

memory.py
3737
3838
3939
40
40
4141
42
43
44
45
46
47
48
49
50
51
52
53
4254
4355
4456
......
5466
5567
5668
69
70
5771
5872
59
73
74
75
76
6077
6178
6279
self.name = name
self.flipped = False
self.highlighted = False
self.normalimage, _ = game.load_image(imagefile)
self.picture, _ = game.load_image(imagefile)
self.cardimages = cardimages
# Generate images for the card, by painting the card's picture onto
# the empty card images...
picw = self.picture.get_width()
pich = self.picture.get_height()
dx = (self.rect.width - picw) / 2
dy = (self.rect.height - pich) / 2
self.cardimage = cardimages[2].copy()
self.cardimage.blit(self.picture, (dx, dy))
self.cardimage_h = cardimages[3].copy()
self.cardimage_h.blit(self.picture, (dx, dy))
self.setimage()
def place(self, x, y):
self.setimage()
pass
# Set the current image based on the state of the card (flipped,
# highlighted)
def setimage(self):
if self.flipped:
self.image = self.normalimage
if self.highlighted:
self.image = self.cardimage_h
else:
self.image = self.cardimage
else:
if self.highlighted:
self.image = self.cardimages[1]

Archive Download the corresponding diff file

Branches