| 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]␊ |