def main():
    g2d.init_canvas((600, 600))
    g2d.set_color((255, 0, 0))

    koch_curve((0, 300), 600, 0)

    g2d.main_loop()
def main():
    width, height = 512, 512
    g2d.init_canvas((width, height))

    g2d.set_color((0, 0, 0))  #sfondo nero
    g2d.fill_rect((0, 0, width, height))
    g2d.set_color((255, 255, 255))

    sierp(0, 0, width, height)
    g2d.main_loop()
Exemple #3
0
import g2d_pyg as g2d


def center(rect: (int, int, int, int)) -> (int, int):
    x, y, w, h = rect
    return x + w / 2, y + h / 2


def htree(rect: (int, int, int, int), level: int):
    x, y, w, h = rect
    if level == 0 or w < 3 or h < 3:
        return
    if level % 2 == 0:
        rect1 = x, y, w / 2, h
        rect2 = x + w / 2, y, w / 2, h
    else:
        rect1 = x, y, w, h / 2
        rect2 = x, y + h / 2, w, h / 2

    g2d.draw_line(center(rect1), center(rect2))
    htree(rect1, level - 1)
    htree(rect2, level - 1)


level = int(input('level? '))  ## -1 = infinite
side = 600

g2d.init_canvas((side, side))
htree((0, 0, side, side), level)

g2d.main_loop()
def main():
    w,h=600,600

    g2d.init_canvas((w,h))
    sierpinski(0,0,w,h)
    g2d.main_loop()
Exemple #5
0
def main():
    g2d.init_canvas(size())
    g2d.handle_keyboard(keydown, keyup)
    g2d.main_loop(update, 1000 // 60)
 def __init__(self):
     self._game = BubbleGame()
     g2d.init_canvas(self._game.arena().size())
     self._sprites = g2d.load_image("bubble_bobble.png")
     # self._sprites = g2d.load_image("https://tomamic.github.io/images/sprites/bubble-bobble.png")
     g2d.main_loop(self.tick)
Exemple #7
0
def gui_play(game: BoardGame):
    g2d.init_canvas((game.cols() * W, game.rows() * H))
    ui = BoardGameGui(game)
    g2d.main_loop(ui.tick)
def main():
    g2d.init_canvas((600, 600))
    h_tree(0 + 10, 0 + 10, 600 - 20, 600 - 20, 10)
    g2d.main_loop()
import g2d_pyg as g2d


def triangle(x, y, w, h, level):
    # caso base
    if level == 0 or w < 5 or h < 5:
        return

    w2 = w / 2
    h2 = h / 2

    # coloro solo il secondo quadrante
    g2d.fill_rect((x + w2, y, w2, h2))

    # applicazione della ricorsione su ogni quandrante rimanente
    triangle(x, y, w2, h2, level - 1)
    triangle(x, y + h2, w2, h2, level - 1)
    triangle(x + w2, y + h2, w2, h2, level - 1)


w, h = 512, 512  #uso una potenza di 2 per non avere degli errori grafici
level = 5
g2d.init_canvas((w, h))

g2d.set_color((0, 0, 0))
g2d.fill_rect((0, 0, w, h))

g2d.set_color((255, 255, 255))
triangle(0, 0, w, h, level)

g2d.main_loop()
Exemple #10
0
def main():
    size = arena.size()
    g2d.init_canvas((size.x, size.y))
    g2d.main_loop(tick)