Commit d2824a47 by BellCodeEditor

auto save

parent f3adb601
Showing with 26 additions and 3 deletions
...@@ -23,5 +23,28 @@ class Ball(pygame.sprite.Sprite): ...@@ -23,5 +23,28 @@ class Ball(pygame.sprite.Sprite):
def main(): def main():
pygame.init() pygame.init()
ball='gray_ball.png' ball='gray_ball.png'
bg='backgound.png' bg_image='backgound.png'
running=True running=True
\ No newline at end of file bg_size=width,height=1048,681
screen=pygame.display.set_mode(bg_size)
pygame.display.set_caption('Play the ball demo')
background=pygame.image.load(bg_image).convert_alpha()
balls=[]
for i in range(5):
position=randint(0,width-100),randint(0,height-100)
speed=[randint(-10,10),randint(-10,10)]
ball=Ball(ball_image,position,speed,bg_size)
balls.append(ball)
clock=pygame.time.Clock()
while running:
for event in pygame.event.get():
if event.type==QUIT:
sys.exit()
screen.blit(background,(0,0))
for each in balls:
each.move()
screen.blit(each.image,each.rect)
pygame.display.flip()
clock.tick(30)
main()
\ 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