def test_tetris_collided_old_pieces(): tetris = Tetris(20, 10) tetris.new_piece() piece = tetris.piece tetris.imprint_piece() tetris.piece = piece assert tetris.collided()
def test_tetris_imprint_piece(): tetris = Tetris(20, 10) tetris.new_piece() piece = tetris.piece tetris.imprint_piece() for p in piece.render(): assert tetris.field[piece.y + p // 4][piece.x + p % 4] == piece.color + 1 pass
def test_tetris_break_line(): tetris = Tetris(20, 10) piece_i1 = Piece(0, 18) piece_i1.type, piece_i1.rotation = 0, 1 tetris.piece = piece_i1 tetris.imprint_piece() piece_i2 = piece_i1 piece_i2.x = 4 tetris.piece = piece_i2 tetris.imprint_piece() piece_o = Piece(7, 17) piece_o.type = 1 tetris.piece = piece_o tetris.imprint_piece() for i, full in enumerate(np.all(tetris.field > 0, axis=1)): if i == 19: assert full else: assert not full tetris.break_line() for i, full in enumerate(np.all(tetris.field > 0, axis=1)): assert not full