def __init__(self, director): super().__init__(director) self.img = SceneHome.get_cards_img() # self.cards = Card.create_cards() # self.cover_card = self.cards[0] self.cover_card_rect = self.cover_card.get_image_rect(SceneHome.RATIO) # self.sli = self.cards[1:53] random.shuffle(self.sli) # white = (255, 255, 255) director.screen.fill(white) # self.dsp_origin_x = 1 self.dsp_origin_y = 1 for i in range(0, 52): m = i // 13 n = i % 13 pos_x = self.dsp_origin_x + n * SceneHome.CARD_WIDTH pos_y = self.dsp_origin_y + m * SceneHome.CARD_HEIGHT #card = self.sli[i] #rect = card.get_image_rect(SceneHome.RATIO) director.screen.blit(self.img, (pos_x, pos_y), self.cover_card_rect) self.card1 = None self.card2 = None self.card1_indices = None self.card2_indices = None self.empty_rect_sur = pygame.Surface( (SceneHome.CARD_WIDTH, SceneHome.CARD_HEIGHT)) self.empty_rect_sur.fill(white)
def __init__(self, director): super().__init__(director) self.img = SceneHome.get_cards_img() # self.cards = Card.create_cards() # self.cover_card = self.cards[0] self.cover_card_rect = self.cover_card.get_image_rect(SceneHome.RATIO) # self.sli = self.cards[1:53] random.shuffle(self.sli) # white = (255, 255, 255) director.screen.fill(white) # self.dsp_origin_x = 1 self.dsp_origin_y = 1 for i in range(0, 52): m = i // 13 n = i % 13 pos_x = self.dsp_origin_x + n * SceneHome.CARD_WIDTH pos_y = self.dsp_origin_y + m * SceneHome.CARD_HEIGHT card = self.sli[i] rect = card.get_image_rect(SceneHome.RATIO) director.screen.blit(self.img, (pos_x, pos_y), rect) self.counter = 0
def __init__(self, director): super().__init__(director) self.img = SceneHome.get_cards_img() # self.cards = Card.create_cards() # self.cover_card = self.cards[0] self.cover_card_rect = self.cover_card.get_image_rect(SceneHome.RATIO) # self.sli = self.cards[1:53] # no shuffle card #random.shuffle(self.sli) # white = (255, 255, 255) director.screen.fill(white) # self.dsp_origin_x = 1 self.dsp_origin_y = 1 for i in range(0, 52): m = i // 13 n = i % 13 pos_x = self.dsp_origin_x + n * SceneHome.CARD_WIDTH pos_y = self.dsp_origin_y + m * SceneHome.CARD_HEIGHT card = self.sli[i] rect = card.get_image_rect(SceneHome.RATIO) director.screen.blit(self.img, (pos_x, pos_y), rect) # create a button font = pygame.font.SysFont("dejavuserif", 36) black = (0, 0, 0) text_sur = font.render("START", True, black) # yellow = (255, 255, 0) button_sur = pygame.Surface(text_sur.get_size()) button_sur.fill(yellow) # button_sur.blit(text_sur, (0, 0)) self.button_rect = director.screen.blit(button_sur, (350, 450)) # self.counter = 0
RATIO = (WIDTH / 13) / Card.CARD_WIDTH CARD_WIDTH = WIDTH // 13 CARD_HEIGHT = int((WIDTH / 13) * (Card.CARD_HEIGHT / Card.CARD_WIDTH)) # white = (255, 255, 255) screen.fill(white) # done = False dir_name = os.path.dirname(os.path.realpath(__file__)) image_path = os.path.join(dir_name, "cards.png") img = pygame.image.load(image_path).convert() #scale(Surface, (width, height), DestSurface = None) -> Surface img = pygame.transform.scale( img, (int(Card.IMAGE_SIZE[0] * RATIO), int(Card.IMAGE_SIZE[1] * RATIO))) # cards = Card.create_cards() # cover_card = cards[0] cover_card_rect = cover_card.get_image_rect(RATIO) # sli = cards[1:53] random.shuffle(sli) # dsp_origin_x = 1 dsp_origin_y = 1 for i in range(0, 52): m = i // 13 n = i % 13 pos_x = dsp_origin_x + n * CARD_WIDTH pos_y = dsp_origin_y + m * CARD_HEIGHT card = sli[i]