Ejemplo n.º 1
0
def main():

    pygame.init()

    # -- Set up game window --
    screen = pygame.display.set_mode([SCR_WIDTH, SCR_HEIGHT])
    pygame.display.set_caption("Aprendiz De Mecânico (demo)")

    # -- Used to set the frame rate --
    clock = pygame.time.Clock()

    # -- Used to maintain/break the main loop --
    done = False

    game = Game()

    # -- Main loop --
    while not done:
        done = game.process_events()

        game.run_logic()

        game.draw_frame(screen)

        clock.tick(60)
        pygame.display.set_caption('Aprendiz De Mecânico (demo): {}fps'.format(
            clock.get_fps()))

    pygame.quit()
Ejemplo n.º 2
0
def main():
    pygame.mixer.pre_init(44100, -16, 2, 2048)
    pygame.init()
    # Set the width and height of the screen [width, height]
    screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
    #Set the title of the window:
    pygame.display.set_caption("Adventure in the sky")
    #Set the mouse invisible.
    pygame.mouse.set_visible(False)
    #Loop until the user clicks the close button.
    done = False
    # Used to manage how fast the screen updates
    clock = pygame.time.Clock()
    try:
        game = Game(screen)  #Create Game Object;
    except pygame.error:
        done = True
    # -------- Main Program Loop -----------
    while not done:
        done = game.eventHandler()
        # Game logic
        game.run_logic()

        # --- Drawing code should go here
        game.displayFrame(screen)
        # --- Go ahead and update the screen with what we've drawn.
        pygame.display.flip()
        # --- Limit to 30 frames per second
        clock.tick(30)
    # Close the window and quit.
    # If you forget this line, the program will 'hang'
    # on exit if running from IDLE.
    pygame.quit()
Ejemplo n.º 3
0
def main():
    pygame.mixer.pre_init(44100, -16, 2, 2048)
    pygame.init()
    # Set the width and height of the screen [width, height]
    screen = pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT))
    #Set the title of the window:
    pygame.display.set_caption("Alien Adventure")
    #Set the mouse invisible.
    pygame.mouse.set_visible(False)
    #Loop until the user clicks the close button.
    done = False
    # Used to manage how fast the screen updates
    clock = pygame.time.Clock()
    try:
        game = Game(screen) #Create Game Object;
    except pygame.error:
        done = True
    # -------- Main Program Loop -----------
    while not done:
        done = game.eventHandler()
        # Game logic
        game.run_logic()
        # --- Drawing code should go here
        game.displayFrame(screen)
        # --- Go ahead and update the screen with what we've drawn.
        pygame.display.flip()
        # --- Limit to 30 frames per second
        clock.tick(30)
    # Close the window and quit.
    # If you forget this line, the program will 'hang'
    # on exit if running from IDLE.
    pygame.quit()