栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

我在此乒乓球比赛中划了一个边界,但球拍可以划过边界。如何停止呢?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

我在此乒乓球比赛中划了一个边界,但球拍可以划过边界。如何停止呢?

为了使球拍保持在场地上,请在游戏循环中添加一个复选标记,以在球拍到达边缘时阻止球拍移动。

.......if pong.rect.x < 10:    pong.rect.x, pong.rect.y = 375, 250    pong.dx = 1    paddle2.points += 1# keep paddles in correct range     # add this sectionif paddle1.rect.y < 0 : paddle1.rect.y = 0if paddle3.rect.y < 0 : paddle3.rect.y = 0if paddle2.rect.y < 200 : paddle2.rect.y = 200if paddle4.rect.y < 200 : paddle4.rect.y = 200if paddle1.rect.y > 200 - 75 : paddle1.rect.y = 200 - 75if paddle3.rect.y > 200 - 75 : paddle3.rect.y = 200 - 75if paddle2.rect.y > 500 - 75 : paddle2.rect.y = 500 - 75if paddle4.rect.y > 500 - 75 : paddle4.rect.y = 500 - 75#if the ball and paddle collide, bounce off itif paddle1.rect.colliderect(pong.rect):    pong.dx = 1if paddle2.rect.colliderect(pong.rect):    pong.dx = -1.....


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/639883.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号