Exemple #1
0
 def draw_prediction(self, screen):
     cur_shape = self.game.get_current_shape()
     if cur_shape is None or not self.predicting:
         return
     predicted = Shape(cur_shape.get_tile())
     predicted.set_position(self.game.get_predicted_points())
     self.draw_shape(screen, predicted, faded=True)
class Test(unittest.TestCase):
    def setUp(self):
        self.shape = Shape(T_TILE)

    def test_create_shape_creates_correct_set_of_initial_points(self):
        self.assertEqual([Point(0, 0), Point(0, -1), Point(-1, 0), Point(0, 1)], self.shape.get_points())

    def test_shape_move_left(self):
        points = [Point(0, -1), Point(0, -2), Point(-1, -1), Point(0, 0)]
        self.shape.set_position(points)
        self.assertEqual(points, self.shape.get_points())
Exemple #3
0
 def draw_next_shape(self, screen):
     next_shape = Shape(self.game.get_next_shape())
     for i in range(0, 2):
         next_shape.set_position(Translation().in_direction(next_shape.get_points(), DOWN))
     pieces=[]
     color = TILE_COLORS[next_shape.get_tile()]
     for point in next_shape.get_points():
         coords = ScreenCoords(row=point.row, col=point.col, tile_width=(screen.get_height()/20))
         pieces.append(DrawableFactory().create_piece(coords, color, next_shape.get_tile().is_empty()))
         
     Center(start=screen.get_height()/2, end=screen.get_width()).pieces_along_x(pieces)
     for piece in pieces:
         piece.draw(screen)
 def setUp(self):
     self.shape = Shape(T_TILE)