python设计小游戏谁先走到17_蜗牛绕墙爬(python小游戏源码)

【实例简介】游戏,蜗牛绕墙爬

【实例截图】

【核心代码】

speed=[5,0]

turtle_right=pygame.transform.rotate(turtle,90)

turtle_top=pygame.transform.rotate(turtle,180)

turtle_left=pygame.transform.rotate(turtle,270)

turtle_bottom=turtle

turtle=turtle_top

while True:

for event in pygame.event.get():

if event.type==QUIT:

sys.exit()

position=position.move(speed)

if position.right>width:

turtle=turtle_right

position=turtle_rect=turtle.get_rect()

position.left=width-turtle_rect.width

speed=[0,5]

if position.bottom>height:

turtle=turtle_bottom

position=turtle_rect=turtle.get_rect()

position.left=width-turtle_rect.width

position.top=height-turtle_rect.height

speed=[-5,0]

if position.left<0:

turtle=turtle_left

position=turtle_rect=turtle.get_rect()

position.top=height-turtle_rect.height

speed=[0,-5]

if position.top<0:

turtle=turtle_top

position=turtle_rect=turtle.get_rect()

speed=[5,0]

screen.fill(bg)

screen.blit(turtle,position)

pygame.display.flip()

clock.tick(30)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值