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()
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()
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)
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()
def main(): size = arena.size() g2d.init_canvas((size.x, size.y)) g2d.main_loop(tick)