本文整理汇总了Python中Ball.Ball.moveBall2方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.moveBall2方法的具体用法?Python Ball.moveBall2怎么用?Python Ball.moveBall2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ball.Ball
的用法示例。
在下文中一共展示了Ball.moveBall2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Ball import Ball [as 别名]
# 或者: from Ball.Ball import moveBall2 [as 别名]
#.........这里部分代码省略.........
sleep(3)
self.tier.undraw()
self.wow.undraw()
return True
else:
return False
def gameOver(self):
# If the ball goes past the paddle, the game is over and the user is asked to play again
xCenter = self.b.getCenter().getX()
xBallLeft = xCenter - self.b.getRadius()
xCenter2 = self.b.getCenter2().getX()
xBallLeft2 = xCenter2 - self.b.getRadius2()
xMiddle = self.p.getMiddle().getX()
xPadRight = xMiddle + 5
if (xBallLeft > xPadRight) or (xBallLeft2 > xPadRight):
loser = Text(Point(250, 150), "GAME OVER!")
loser.setSize(25)
loser.setTextColor("red")
again = Text(Point(250, 200), "PLAY AGAIN?")
again.setSize(25)
again.setTextColor("red")
loser.draw(self.pWin)
again.draw(self.pWin)
return True
def restart(self):
# If the player types 'yes', the game will restart completely
restart = input("\nWould You Like To Restart (yes/no)? ")
if restart.lower() == "yes":
self.pWin.close()
newGame = Pong()
print("WARNING!! IN SHRINKING MODE, PADDLE RESETS TO MIDDLE AFTER EACH LEVEL")
game = input("Which version would you like to play: 'shrinking mode' (s), 'multiple mode' (m), or 'normal mode' (n)? ")
newGame.play(game)
else:
self.pWin.close()
def play(self, ans):
# The user will be given 3 seconds after asked to play until the game begins
sleep(1)
self.ready = Text(Point(250, 81), "Are You Ready?")
self.ready.setSize(30)
self.ready.setTextColor("red")
self.ready.draw(self.pWin)
self.three = Text(Point(250, 200), "THREE")
self.three.setSize(35)
self.three.setTextColor("white")
self.three.draw(self.pWin)
sleep(1)
self.three.undraw()
self.two = Text(Point(250, 200), "TWO")
self.two.setSize(35)
self.two.setTextColor("white")
self.two.draw(self.pWin)
sleep(1)
self.two.undraw()
self.one = Text(Point(250, 200), "ONE")
self.one.setSize(35)
self.one.setTextColor("white")
self.one.draw(self.pWin)
sleep(1)
self.one.undraw()
self.ready.undraw()
while True:
click = self.pWin.checkMouse()
if click != None:
self.p.movePad(click)
if ans.lower() == 's':
if self.checkContactShrink():
self.b.reverseX()
elif ans.lower() == 'm':
if self.checkContactBallA():
self.b.reverseX()
if self.checkContactBallB():
self.b.reverse2X()
self.b.moveBall2(self.pWin)
elif ans.lower() == 'n':
if self.checkContact():
self.b.reverseX()
else:
print("\nOh Well, I Didn't Want To Play With You Anyway!")
self.b.moveBall(self.pWin)
if self.gameOver():
self.restart()