本文整理匯總了Python中Ball.Ball.getRadius2方法的典型用法代碼示例。如果您正苦於以下問題:Python Ball.getRadius2方法的具體用法?Python Ball.getRadius2怎麽用?Python Ball.getRadius2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Ball.Ball
的用法示例。
在下文中一共展示了Ball.getRadius2方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from Ball import Ball [as 別名]
# 或者: from Ball.Ball import getRadius2 [as 別名]
#.........這裏部分代碼省略.........
if (xBallRight >= xPadLeft and yBallBottom >= yPadTop) and (xBallRight >= xPadLeft and yBallTop <= yPadBottom):
self.hits += 1
self.score += 1
self.userScore.setText(self.score)
if self.hits % 4 == 0:
self.level += 1
self.userLevel.setText(self.level)
self.b.goFaster()
if self.level % 10 == 0:
self.tier = Text(Point(250, 250), "You have reached a new tier")
self.tier.setTextColor("red")
self.tier.setSize(20)
self.tier.draw(self.pWin)
self.wow = Text(Point(250, 81), "WOW!")
self.wow.setSize(30)
self.wow.setTextColor("red")
self.wow.draw(self.pWin)
sleep(3)
self.tier.undraw()
self.wow.undraw()
return True
else:
return False
# Second Ball Used for Multiple-Ball Pong
def checkContactBallB(self):
xMiddle = self.p.getMiddle().getX()
xPadLeft = xMiddle - 5
xPadRight = xMiddle + 5
xCenter2 = self.b.getCenter2().getX()
xBallRight2 = xCenter2 + self.b.getRadius2()
xBallLeft2 = xCenter2 - self.b.getRadius2()
yMiddle = self.p.getMiddle().getY()
yPadTop = yMiddle - 50
yPadBottom = yMiddle + 50
yCenter2 = self.b.getCenter2().getY()
yBallTop2 = yCenter2 - self.b.getRadius2()
yBallBottom2 = yCenter2 + self.b.getRadius2()
# If the x value of right side of the ball is = to the x value of the left side of the paddle,
# and the y value of the top/bottom of the ball is not outside the y value of the top/bottom of the paddle,
# then the ball has made contact
if (xBallRight2 >= xPadLeft and yBallBottom2 >= yPadTop) and (xBallRight2 >= xPadLeft and yBallTop2 <= yPadBottom):
self.hits += 1
self.score += 1
self.userScore.setText(self.score)
if self.hits % 4 == 0:
self.level += 1
self.userLevel.setText(self.level)
self.b.goFaster()
if self.level % 3 == 0:
self.tier = Text(Point(250, 250), "You have reached a new tier")
self.tier.setTextColor("red")
self.tier.setSize(20)
self.tier.draw(self.pWin)
self.wow = Text(Point(250, 81), "WOW!")
self.wow.setSize(30)
self.wow.setTextColor("red")
self.wow.draw(self.pWin)