Commit 2dfd572f by BellCodeEditor

save project

parent ea0547e0
Showing with 32 additions and 0 deletions
import pygame
pygame.init()
size = width, height = 600,400
f = pygame.time.Clock()
speed = [1,1]
BLACK = 0,0,0
screen = pygame.display.set_mode((600,400))
pygame.display.set_caption("Pygame壁球")
ball = pygame.image.load("pyg02-ball.gif")
ballrect = ball.get_rect()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
ballrect = ballrect.move(speed[0],speed[1])
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(BLACK)
screen.blit(ball,ballrect)
pygame.display.update()
f.tick(400)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment