Created
August 20, 2012 16:19
-
-
Save siwells/3405456 to your computer and use it in GitHub Desktop.
PyGame Moving line Animation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| import pygame | |
| y = 0 | |
| dir = 1 | |
| running = 1 | |
| width = 800 | |
| height = 600 | |
| screen = pygame.display.set_mode((width, height)) | |
| linecolor = 255, 0, 0 | |
| bgcolor = 0, 0, 0 | |
| while running: | |
| event = pygame.event.poll() | |
| if event.type == pygame.QUIT: | |
| running = 0 | |
| screen.fill(bgcolor) | |
| pygame.draw.line(screen, linecolor, (0, y), (width-1, y)) | |
| y += dir | |
| if y == 0 or y == height-1: dir *= -1 | |
| pygame.display.flip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment