예제 #1
0
def main():
    pygame.init()
    clock = pygame.time.Clock()  
    pygame.key.set_repeat(1, 50)
    size = FIELD_SIZE, FIELD_SIZE
    screen = pygame.display.set_mode(size)
    font = pygame.font.SysFont("Courier New", 18)
    black = 0, 0, 0
    
    ball = Particle(screen.get_rect(), max_speed=15, color=(125,5,230), gravity=GRAVITY,friction=FRICTION_COEFFICIENT)
    
    done = False
    
    while not done:
        dt = clock.tick(FRAME_RATE) #limit to 120 fps
        screen.fill(black)
        read_keyboard()
        
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True
                
        # ball.move_keyboard(pygame.key.get_pressed(),KEY_ACCEL)
        ball.move_mouse(50/FRAME_RATE)
        ball.movetowards((450,450),KEY_ACCEL)
        
        ball.move()
        ball.draw(screen)  
        
        pygame.display.flip()
    pygame.quit()