예제 #1
0
 def __init__(self):
     matrix = Matrix([
         [1, 0, 0],
         [1, 1, 1],
     ])
     self.color = colorama.Fore.BLUE
     super().__init__(matrix=matrix)
예제 #2
0
 def __init__(self):
     matrix = Matrix([
         [0, 0, 1],
         [1, 1, 1],
     ])
     self.color = colorama.Fore.YELLOW
     super().__init__(matrix=matrix)
예제 #3
0
 def __init__(self):
     matrix = Matrix([
         [0, 1, 0],
         [1, 1, 1],
     ])
     self.color = colorama.Fore.MAGENTA
     super().__init__(matrix=matrix)
예제 #4
0
 def __init__(self, grid: Grid):
     super().__init__()
     self.matrix : Matrix = Matrix.empty_sized(rows=4, columns=7)
     self.matrix = self.matrix.with_border(MatrixBorder(sides=MatrixBorder.SINGLE_LINE_THIN))
     self.position = Vector2(grid.position.x + grid.size.x + 1, grid.position.y)
     self.current_shape = self.get_random_shape()
     self.set_start_shape_position()
예제 #5
0
 def __init__(self, **kwargs):
     # for type hinting
     self._matrix: Matrix = None
     self._position: Vector2 = None
     # set the real thing
     self.matrix = kwargs.get('matrix', Matrix())
     self.position = kwargs.get('position', Vector2(x=0, y=0))
예제 #6
0
 def __init__(self, height, width):
     self.empty_char = '.'  # '°'
     self.position = Vector2(x=5, y=0)
     matrix = Matrix.empty_sized(rows=height, columns=width, value='.')
     matrix = matrix.with_border(
         MatrixBorder(sides=MatrixBorder.DOUBLE_LINE))
     super().__init__(matrix=matrix)
예제 #7
0
 def __init__(self, grid: Grid, height, width):
     # making this grid the exact same size as the main grid makes it easier to work with
     self.position = grid.position.clone()
     # currenly this value only increase, and never goes down when lines clear
     # highest Piece is actually the lowest value for y
     self.highest_piece = height
     # border offset
     self.matrix = Matrix.empty_sized(rows=height, columns=width, value=0)
     self.char = '▢'
예제 #8
0
from frolic.matrix import Matrix, Vector2

e = Matrix([
    [
        1,
        2,
    ],
    [
        6,
        3,
    ],
    [
        5,
        4,
    ],
])

e_rotated = e.rotated()
print(e_rotated)

a = Matrix([
    [1, 2, 3],
    [8, 0, 4],
    [7, 6, 5],
])
print(a)
assert a[0][0] == 1
assert a[0][1] == 2
assert a[0][2] == 3
assert a[1][0] == 8
assert a[1][1] == 0
예제 #9
0
 def __init__(self):
     matrix = Matrix([
         [1, 1, 1, 1]
     ])
     self.color = colorama.Fore.CYAN
     super().__init__(matrix=matrix)
예제 #10
0
from frolic.matrix import Matrix
from frolic.matrix_border import MatrixBorder

matrix1 = Matrix.empty_sized(rows=3, columns=4, value='.')
print(matrix1)
border = MatrixBorder()
print(matrix1.with_border(border))

matrix2 = Matrix.empty_sized(rows=5, columns=5, value='°')
matrix2[2][2] = 'A'
border = MatrixBorder(sides=MatrixBorder.DOUBLE_LINE)
print(matrix2.with_border(border))
print(matrix2)
예제 #11
0
 def __init__(self, rows=0, columns=0):
     # _matrix is intended to only be modified
     # by this or other instances of the Screen class
     self._matrix = Matrix.empty_sized(rows=rows,
                                       columns=columns,
                                       value=None)
예제 #12
0
 def draw_string(self, string: str, position: Vector2):
     self.draw_matrix(Matrix([string]), position)