예제 #1
0
 def __init__(self):
     m = Matrix.empty_sized(20, 20, '.')
     tree = Tree()
     m = m.apply(tree.matrix, Vector2(2, 2))
     m = m.apply(tree.matrix, Vector2(6, 8))
     m = m.apply(tree.matrix, Vector2(3, 12))
     m = m.apply(tree.matrix, Vector2(12, 15))
     super().__init__(matrix=m)
예제 #2
0
 def __init__(self):
     super().__init__()
     self.position = Vector2(x=2, y=2)
     self.matrix = Matrix.empty_sized(rows=6, columns=6, value=' ')
     self.matrix[1][1] = '2'
     # ♤ ♡ ♧ ♢
     self.matrix[2][1] = '♤'
예제 #3
0
 def __init__(self):
     super().__init__()
     self.position = Vector2(x=2, y=1)
     _matrix = Matrix.empty_sized(rows=6, columns=6, value=" ")
     _matrix[1][1] = "2"
     # ♤ ♡ ♧ ♢
     _matrix[2][1] = "♤"
     border = MatrixBorder()
     self.matrix = _matrix.with_border(border)
예제 #4
0
    def draw(self, screen: Screen):

        display_matrix = self.background.matrix.clone()
        display_matrix = display_matrix.apply(self.player.matrix,
                                              self.player.position)
        display_matrix = display_matrix.with_border(
            MatrixBorder(MatrixBorder.DOUBLE_LINE))

        viewport = Matrix.empty_sized(10, 20)
        player_pos = self.player.position
        offset = viewport.size.scale(0.5)
        offset.x = int(offset.x)
        offset.y = int(offset.y)
        viewport = viewport.apply(
            display_matrix,
            Vector2(-player_pos.x + offset.x, -player_pos.y - 1 + offset.y))
        viewport = viewport.with_border(
            MatrixBorder(MatrixBorder.SINGLE_LINE_THIN))

        screen.draw_matrix(viewport, Vector2(0, 0))
예제 #5
0
from frolic import Vector2
import colorama

GREEN = colorama.Fore.GREEN
RED = colorama.Fore.RED
BRIGHT = colorama.Style.BRIGHT
RESET_ALL = colorama.Style.RESET_ALL

print('\nVector2 Test\n')
try:
    v1 = Vector2(2, 4)
    v2 = Vector2(x=3, y=5)
    v3 = Vector2(y=4, x=6)
    test = 'v1.x == 2'
    assert (eval(test))
    test = 'v1.y == 4'
    assert (eval(test))
    test = 'v2.x == 3'
    assert (eval(test))
    test = 'v2.y == 5'
    assert (eval(test))
    test = 'v3.x == 6'
    assert (eval(test))
    test = 'v3.y == 4'
    assert (eval(test))
    print(f'{GREEN}{BRIGHT}PASSED:{RESET_ALL} assignment')
except:
    print(f'{RED}{BRIGHT}FAILED:{RESET_ALL} assignment "{test}"')

try:
    v1 = Vector2(x=3, y=4)
예제 #6
0
 def __init__(self):
     self.background = Background()
     self.player = Player()
     self.player.position = Vector2(2, 2)
     m = Matrix.empty_sized()
     super().__init__(matrix=m)
예제 #7
0
 def __init__(self):
     super().__init__()
     self.position = Vector2(x=5, y=0)
     self.matrix = Matrix.empty_sized(rows=3, columns=2, value="0")