Exemple #1
0
cyclesPerSecond = args.fps
###########################

bonkFpsData = [[],[], []]

crashed = False
while cycleCount < args.cycles and not crashed:
    ## event handling
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            crashed = True

    ## logic
    start = pygame.time.get_ticks()
    world.performCycle(cycleCount)
    timeTook = pygame.time.get_ticks() - start
    print("Cycle {} ({} bonks): took {}ms ".format(str(cycleCount), world.bonkTotal, str(timeTook)))
    ## draw stuff
    gameDisplay.fill(WHITE)
    world.draw(gameDisplay)
    ## end
    pygame.display.flip() ## redraw screen
    clock.tick(cyclesPerSecond) ## 1 cycle per second
    cycleCount += 1

    bonkFpsData[0].append(cycleCount)
    bonkFpsData[1].append(timeTook)
    bonkFpsData[2].append(world.bonkTotal)

gameDisplay.fill(WHITE)