def main(): win = Window(fullscreen=True) win.on_resize = on_resize try: try: install_shaders('allGreen.frag', 'zoomRotate.vert') except ShaderError, e: print str(e) return 2 win.on_draw = lambda: on_draw(win) app.run()
def main(): win = Window(fullscreen=True, visible=False) camera = Camera(win.width, win.height, (0, 0), 100) renderer = Renderer() maze = Maze() maze.create(50, 30, 300) keyboard = Keyboard() keyboard.key_handlers[key.ESCAPE] = win.close keyboard.key_handlers.update(camera.key_handlers) clock.schedule(maze.update) win.on_draw = lambda: renderer.on_draw(maze, camera, win.width, win.height) win.on_key_press = keyboard.on_key_press keyboard.print_handlers() win.set_visible() app.run()
win = Window(fullscreen=True, visible=False) camera = Camera((0, 0), 10) renderer = Renderer() army_shape = Army.MakeShape(400, 1500, all_ghosts) armies = [] for i in range(20, 0, -1): army = Creature(army_shape, rand_point(500), uniform(-pi, pi)) army.dx = uniform(-0.4, +0.4) army.dy = uniform(-0.4, +0.4) armies.append(army) def update(dt): for army in armies: army.update(dt) camera.zoom(1.003) clock.schedule(update) key_handlers[key.ESCAPE] = win.close win.on_draw = lambda: renderer.on_draw(armies, camera, win.width, win.height) win.on_key_press = on_key_press print "keys to try:", [symbol_string(k) for k in key_handlers.keys()] stdout.flush() win.set_visible() app.run()
def make_army(size, menagerie): army = [] for col in range(size): for row in range(size): creature_type = menagerie[randint(0, len(menagerie)-1)] x = (col+0.5)*16 - size * 8 y = (row+0.5)*16 - size * 8 creature = Creature(creature_type, (x, y)) creature.da = uniform(-0.1, +0.1) creature.velocity = uniform(0, +0.5) army.append(creature) return army creatures = make_army(12, [blue_ghost, orange_ghost, pacman, pink_ghost, red_ghost]) def update(dt): for creature in creatures: creature.update(dt) clock.schedule(update) key_handlers[key.ESCAPE] = win.close win.on_draw = lambda: renderer.on_draw(creatures, camera, win.width, win.height) win.on_key_press = on_key_press print "keys to try:", [symbol_string(k) for k in key_handlers.keys()] stdout.flush() win.set_visible() app.run()
from renderer import Renderer win = Window(fullscreen=True, visible=False) camera = Camera((0, 0), 10) renderer = Renderer() army_shape = Army.MakeShape(400, 1500, all_ghosts) armies = [] for i in range(20, 0, -1): army = Creature(army_shape, rand_point(500), uniform(-pi, pi)) army.dx = uniform(-0.4, +0.4) army.dy = uniform(-0.4, +0.4) armies.append(army) def update(dt): for army in armies: army.update(dt) camera.zoom(1.003) clock.schedule(update) key_handlers[key.ESCAPE] = win.close win.on_draw = lambda: renderer.on_draw(armies, camera, win.width, win.height) win.on_key_press = on_key_press print "keys to try:", [symbol_string(k) for k in key_handlers.keys()] stdout.flush() win.set_visible() app.run()