python-は少し亀を浮かべ

すぐに壁に当たった後、背中に浮かん小さなカメ

1  インポートpygameの
 2  インポートSYS
 3  
4  pygame.init()
 5 =幅、高さ= 600、600サイズ
 6速度= [-2、1 ]
 7 BG =(254、254、254 8の画面= pygame.display.set_mode (サイズ)
 9 pygame.display.set_caption(" パイソン小乌龟" 10亀= pygame.image.load(" turtle.png " 11位置= turtle.get_rect()
 12  一方TRUE:
 13      のためのイベントpygame.event.get(): 
 14          なら event.type == pygame.QUIT:
 15              sys.exit()
 16      位置= position.move(速度)
 17      なら position.left <0 または position.right> 幅:
 18          カメ= pygame.transform.flip(カメ、真、偽)
 19          速度[0] = - 速度[0]が
 20      であれば position.top <0 または position.bottom> 高さ:
 21          速度[1] =倍速[-1 ]
 22      screen.fill(BG)
 23      screen.blit(カメ、位置)
24      pygame.display.flip()
 25      pygame.time.delay(10 26     

次のような効果があります

 

 

 

 

 

おすすめ

転載: www.cnblogs.com/cjl0706/p/12029216.html