Exemplo n.º 1
0
def main():

    localeHandler = AppLocale(Constants.LOCALE)
    my_clock = pygame.time.Clock()
    frameCounter = 0
    """ Set up the game and run the main game loop """
    pygame.init()  # Prepare the pygame module for use
    mainWindow = Window(localeHandler, Conway)
    mainWindow.setWindowUpdateSpeed(1000)

    while True:
        ev = pygame.event.poll()  # Look for any event
        if ev.type == pygame.QUIT:  # Window close button clicked?
            break  #   ... leave game loop
        keys = pygame.key.get_pressed()
        if keys[pygame.K_ESCAPE]:
            break

        # handle MOUSEBUTTONUP
        if ev.type == pygame.MOUSEBUTTONUP:
            pos = pygame.mouse.get_pos()

            if not mainWindow.isPlayPauseButtonPressed(pos):
                mainWindow.toggleCell(pos)

        if ev.type == mainWindow.WINDOW_UPDATE_ID:
            mainWindow.updateWindow()

        pygame.display.update()

        #force a constant frame rate of 60fps
        my_clock.tick(Constants.FRAME_RATE)

    pygame.quit()  # Once we leave the loop, close the window.
Exemplo n.º 2
0
def main():

    localeHandler = AppLocale(Constants.LOCALE)
    my_clock = pygame.time.Clock()
    frameCounter = 0

    """ Set up the game and run the main game loop """
    pygame.init()  # Prepare the pygame module for use
    mainWindow = Window(localeHandler, Conway)
    mainWindow.setWindowUpdateSpeed(1000)

    while True:
        ev = pygame.event.poll()    # Look for any event
        if ev.type == pygame.QUIT:  # Window close button clicked?
            break                   #   ... leave game loop
        keys = pygame.key.get_pressed()
        if keys[pygame.K_ESCAPE]:
            break

        # handle MOUSEBUTTONUP
        if ev.type == pygame.MOUSEBUTTONUP:
            pos = pygame.mouse.get_pos()

            if not mainWindow.isPlayPauseButtonPressed(pos):
                mainWindow.toggleCell(pos)

        if ev.type == mainWindow.WINDOW_UPDATE_ID:
            mainWindow.updateWindow()

        pygame.display.update()

        #force a constant frame rate of 60fps
        my_clock.tick(Constants.FRAME_RATE)

    pygame.quit()     # Once we leave the loop, close the window.
Exemplo n.º 3
0
def main():

    my_clock = pygame.time.Clock()
    config = Config()
    """ Set up the game and run the main game loop """
    pygame.init()  # Prepare the pygame module for use
    mainWindow = Window(Model(GerritRequester(config)))

    # you have to call this at the start,
    pygame.font.init()

    while True:
        try:
            pos = 0

            ev = pygame.event.poll()  # Look for any event
            if ev.type == pygame.QUIT:  # Window close button clicked?
                break  #   ... leave game loop
            keys = pygame.key.get_pressed()
            if keys[pygame.K_ESCAPE]:
                break

            # handle MOUSEBUTTONUP
            if ev.type == pygame.MOUSEBUTTONUP:
                pos = pygame.mouse.get_pos()

            mainWindow.updateWindow(pos)
            pygame.display.update()

            #force a constant frame rate of 60fps
            my_clock.tick(Constants.FRAME_RATE)
        except KeyboardInterrupt:
            break

    mainWindow.clean()
    pygame.quit()  # Once we leave the loop, close the window.