Example #1
0
 def restart(self):
   self.occupied = [[False]*self.height for i in range(self.width)]
   self.pattern = [[None]*self.height for i in range(self.height)]
   default_surface = [make_surface(BLACK), make_surface(GRAY)]
   self.default = [[default_surface[(i+j) % 2] for j in range(self.height)] for i in range(self.height)]
   # gameover flag
   self.gameover = False
   # mino pack generator
   self.generator = Generator()
   # next queue
   self.nextminos = [self.generator.next_mino() for x in range(self.next_size)]
   # current piece
   self.mino = self.pop_nextmino()
   # hold piece and hold flag
   self.hold = None
   self.holdflag = True
   # recieved attack buffer
   self.atk_buffer = []
  
   '''   game status   '''
   # game info (total lines, total attack, combo, b2b)
   self.info = GameInfo()
   # line clear
   self.lineClear = 0
   # T-spin flag
   self.tSpin = False
   self.tSpinDisplay = False
Example #2
0
 def drawBuffer(self, color, linewidth):
   surface = pygame.Surface((BUFFER_WIDTH, self.height*BLOCK_WIDTH))
   transform = lambda y: (0, (self.height-1-y)*BLOCK_WIDTH)
   buffer_sum = sum(self.atk_buffer)
   for i in range(min(buffer_sum, self.height)):
     bar = make_surface(RED, (BUFFER_WIDTH, BLOCK_WIDTH))
     surface.blit(bar, transform(i))
   # add frame
   surface = add_frame(surface, color, linewidth)
   return surface
Example #3
0
def Mino_Z(center):
  return Mino(                                        \
    center      = center,                             \
    pos         = [(-1, 1), (0, 1), (0, 0), (1, 0)],  \
    isT         = False,                              \
    orientation = 0,                                  \
    turn_enable = True,                               \
    turn_center = ((0, 0), (0, 0)),                   \
    turn_table  = SRS_TJLSZ,                          \
    pattern     = make_surface(GREEN)                 \
)
Example #4
0
def Mino_T(center):
  return Mino(                                        \
    center      = center,                             \
    pos         = [(-1, 0), (0, 0), (1, 0), (0, 1)],  \
    isT         = True,                               \
    orientation = 0,                                  \
    turn_enable = True,                               \
    turn_center = ((0, 0), (0, 0)),                   \
    turn_table  = SRS_TJLSZ,                          \
    pattern     = make_surface(MAGENTA)               \
)
Example #5
0
def Mino_O(center):
  return Mino(                                        \
    center      = center,                             \
    pos         = [(0, 0), (0, 1), (1, 0), (1, 1)],   \
    isT         = False,                              \
    orientation = 0,                                  \
    turn_enable = False,                              \
    turn_center = ((0, 0), (0, 0)),                   \
    turn_table  = None,                               \
    pattern     = make_surface(YELLOW)                \
)
Example #6
0
def Mino_I(center):
  return Mino(                                        \
    center      = center,                             \
    pos         = [(-1, 0), (0, 0), (1, 0), (2, 0)],  \
    isT         = False,                              \
    orientation = 0,                                  \
    turn_enable = True,                               \
    turn_center = ((1, 0), (0, -1)),                  \
    turn_table  = SRS_I,                              \
    pattern     = make_surface(CYAN)                  \
)
Example #7
0
 def clearAttack(self):
   for atk in self.atk_buffer:
     hole = random.randint(0, self.width-1)
     for j in range(self.height-1, -1, -1):
       for i in range(self.width):
         if j >= atk:
           self.occupied[i][j] = self.occupied[i][j-atk]
           self.pattern[i][j] = self.pattern[i][j-atk]
         else:
           self.occupied[i][j] = False if i == hole else True
           self.pattern[i][j] = None if i == hole else make_surface(SILVER)
   self.atk_buffer = []
Example #8
0
 def ghost(self, field):
   mino = self.copy()
   mino.pattern = make_surface(GHOST)
   while mino.move((0, -1), field): pass
   return mino