Exemple #1
0
def main():
    pygame.init()

    display = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
    pygame.display.set_caption("TETRIS")

    block = Block()
    pace = Pace()
    score = Score()
    grid = Grid()
    level = Level(block, grid, score, pace)
    clock = Clock()
    event_queue = Event()
    game_renderer = GameRenderer(display, level)
    ui_renderer = UIRenderer(display)

    name_input = PlayerName(ui_renderer, event_queue)
    game_loop = GameLoop(level, clock, event_queue, game_renderer,
                         score_repository)
    high_scores = HighScores(ui_renderer, event_queue, score_repository)
    main_menu = MainMenu(ui_renderer, event_queue, name_input, game_loop,
                         high_scores)

    main_menu.start()
Exemple #2
0
 def setUp(self):
     self.level = Level(Block(), Grid(), Score(), Pace())
     self.level.block.shape = [[1],
                               [1],
                               [1],
                               [1]]
Exemple #3
0
 def setUp(self):
     self.score = Score()
Exemple #4
0
class TestScore(unittest.TestCase):
    def setUp(self):
        self.score = Score()

    def test_constructor_sets_score_to_zero(self):
        self.assertEqual(self.score.score, 0)

    def test_constructor_sets_counter_to_zero(self):
        self.assertEqual(self.score._Score__counter, 0)

    def test_add_score_adds_points_given_as_argument_to_score(self):
        self.score.add_score(5)
        self.assertEqual(self.score.score, 5)

    def test_add_score_adds_points_by_one(self):
        self.score.add_score(5)
        self.assertEqual(self.score._Score__counter, 1)

    def test_check_score_resets_counter_if_counter_eq_15(self):
        for i in range(15):
            self.score.add_score(1)
        self.score.check_score()
        self.assertEqual(self.score._Score__counter, 0)

    def test_check_score_doesnt_reset_counter_if_counter_lt_15(self):
        for i in range(5):
            self.score.add_score(1)
        self.score.check_score()
        self.assertEqual(self.score._Score__counter, 5)

    def test_check_score_returns_true_if_counter_eq_15(self):
        for i in range(15):
            self.score.add_score(1)
        self.assertTrue(self.score.check_score())

    def test_check_score_returns_false_if_counter_lt_15(self):
        self.score.add_score(1)
        self.assertFalse(self.score.check_score())
 def setUp(self):
     self.level = Level(Block(), Grid(), Score(), Pace())