示例#1
0
def main():
    graphics = BreakoutGraphics()
    live = NUM_LIVES
    score = graphics.scores

    # Add animation loop here!
    while True:

        pause(FRAME_RATE)
        if graphics.ball.y + graphics.ball.height >= graphics.window.height:
            live -= 1
            if live > 0:
                graphics.reset_ball()
            else:
                graphics.gameover()
                break

        dx = graphics.get_vx()
        dy = graphics.get_vy()
        graphics.ball.move(dx, dy)
        graphics.sensor()
        # graphics.box_sensor()
        # graphics.drop_a_gift()
        # graphics.box.move(0,5)
        graphics.end()

        if score == 3:
            graphics.window.add()

        if graphics.ball.x <= 0 or graphics.ball.x + graphics.ball.width >= graphics.window.width:
            graphics.reverse_vx()
        if graphics.ball.y <= 0:
            graphics.reverse_vy()
示例#2
0
def main():


    rate = FRAME_RATE     # To speed up
    lives = NUM_LIVES     # Easy to set lives
    graphics = BreakoutGraphics()

    while lives > 0:
        graphics.check()            # Determine the state of the ball and other objects
        graphics.faster(rate)       # Speed up the game

        if graphics.lose():         # Determine whether to lose
            graphics.reset()        # Reset the position and speed of the ball
            lives = graphics.lives_time(lives)
            graphics.print_lives()


        pause(rate)

    graphics.end()