Skip to content

Instantly share code, notes, and snippets.

@joetechem
Created April 20, 2017 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joetechem/54902bf528a6fe7ca746b2ed6cdd1d28 to your computer and use it in GitHub Desktop.
Save joetechem/54902bf528a6fe7ca746b2ed6cdd1d28 to your computer and use it in GitHub Desktop.
import sys, pygame
pygame.init()
size = width, height = 600, 600
speed = [1, 1]
red = 130, 202, 154
screen = pygame.display.set_mode(size)
# ball = pygame.image.load("pygame_logo.gif")
ball = pygame.image.load("TechEmDogKoa1.jpg")
ballrect = ball.get_rect()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
ballrect = ballrect.move(speed)
if ballrect.left < 0 or ballrect.right > width:
speed[0] = -speed[0]
if ballrect.top < 0 or ballrect.bottom > height:
speed[1] = -speed[1]
screen.fill(red)
screen.blit(ball, ballrect)
pygame.display.flip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment