import sys, pygame
pygame.init()

size=width, height = 600, 240
balloffset = [1, 2]
white = 255,255,255

screen = pygame.display.set_mode(size)

ball = pygame.image.load("ball.bmp")
ballrect = ball.get_rect()

while 1:
	for event in pygame.event.get():
		if event.type == pygame.QUIT: sys.exit()

	ballrect = ballrect.move(balloffset)
	if ballrect.left < 0 or ballrect.right > width:
		balloffset[0] = -balloffset[0]
	if ballrect.top < 0 or ballrect.bottom > height:
		balloffset[1] = -balloffset[1]
	
	screen.fill(white)
	screen.blit(ball, ballrect)
	pygame.display.update()
	pygame.time.delay(50)

