Ejemplo n.º 1
0
# parse arguments
if len(sys.argv) > 1:
    if "wave" in sys.argv:
        make_wave()
    
    if "empty" in sys.argv:
        game.initBoard(0)
else:
    game.initBoard(ncreatures)


board = win.add_group(drawBoard(game.board))


#=============================================================================
# animate

print "animating"

def animate():
    global timer, board
    
    if not win.is_open():
        timer.stop()
    else:
        game.evolve()
        board = board.replace_self(drawBoard(game.board))

timer = summon.add_timer(animate, .2)
Ejemplo n.º 2
0
 def start(self, interval=.05):
     self.timer = summon.add_timer(self.update, interval, window=win)
Ejemplo n.º 3
0
for i in range(nballs):
    angle = random.random()
    vx = 5 * math.cos(angle)
    vy = 5 * math.sin(angle)
    size = maxballsize * i/ float(nballs)
    x = size + (winsize - 2 * size) * random.random()
    y = size + (winsize - 2 * size) * random.random()
    
    balls.append(Ball(x, y, size, vx, vy))



# create window
win = summon.Window("15_animation")

# draw bounding box
win.add_group(group(color(1,1,1), shapes.box(0, 0, winsize, winsize, fill=False)))

# draw frame per second display
fps_vis = win.screen.add_group(
    group(
        color(1, 1, 1),
        text("FPS: 0", 5, 5, 300, 25, "left", "bottom")))

# center view
win.home()


# setup timer to call the draw frame function
timer = summon.add_timer(draw_frame, interval=rate, window=win)
Ejemplo n.º 4
0
    vis.extend([i, 0, i, 100])
win.add_group(lines(*vis))
print "extend      ", summon.get_time() - start

win.clear_groups()


#=============================================================================
start = summon.get_time()
vis = []
n = float(nlines)
for i in xrange(nlines):
    vis.extend([color(i/n, 0, 1), i, 0, i, 100])
win.add_group(lines(*vis))
print "extend color", summon.get_time() - start

win.clear_groups()


#=============================================================================
def func():
    start = summon.get_time()
    vis = []
    for i in xrange(nlines):
        vis.extend([i, 0, i, 100])
    win.add_group(lines(*vis))
    print "1 thread    ", summon.get_time() - start

summon.add_timer(func, repeat=False)