コード例 #1
0
ファイル: field.py プロジェクト: music960633/PyTetris
 def drawHold(self, color, linewidth):
   surface = pygame.Surface((4*BLOCK_WIDTH, 4*BLOCK_WIDTH))
   transform = lambda (x, y): (x*BLOCK_WIDTH, (3-y)*BLOCK_WIDTH)
   # hold piece
   if self.hold is not None:
     fx, fy = 2*BLOCK_WIDTH, 2*BLOCK_WIDTH
     cx, cy = find_center(self.hold.get_pos())
     for x, y in self.hold.get_pos():
       surface.blit(self.hold.pattern, (int(fx + (x-cx-0.5)*BLOCK_WIDTH), int(fy + (-y+cy-0.5)*BLOCK_WIDTH)))
   # resize to hold size
   surface = pygame.transform.scale(surface, HOLD_SIZE)
   # add frame
   surface = add_frame(surface, color, linewidth)
   return surface
コード例 #2
0
ファイル: field.py プロジェクト: music960633/PyTetris
 def drawNext(self, color, linewidth):
   surfaceList = []
   transform = lambda (x, y): (x*BLOCK_WIDTH, (3-y)*BLOCK_WIDTH)
   for i in range(self.next_size):
     nextmino = self.nextminos[i]
     surface = pygame.Surface((4*BLOCK_WIDTH, 4*BLOCK_WIDTH))
     fx, fy = 2*BLOCK_WIDTH, 2*BLOCK_WIDTH
     cx, cy = find_center(nextmino.get_pos())
     for x, y in nextmino.get_pos():
       surface.blit(nextmino.pattern, (int(fx + (x-cx-0.5)*BLOCK_WIDTH), int(fy + (-y+cy-0.5)*BLOCK_WIDTH)))
     # resize to next size
     surface = pygame.transform.scale(surface, NEXT_SIZE)
     # add frame
     surface = add_frame(surface, color, linewidth)
     # add to list
     surfaceList.append(surface)
   return surfaceList