本文整理汇总了Python中Ball.Ball.score方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.score方法的具体用法?Python Ball.score怎么用?Python Ball.score使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ball.Ball
的用法示例。
在下文中一共展示了Ball.score方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Paddle
# 需要导入模块: from Ball import Ball [as 别名]
# 或者: from Ball.Ball import score [as 别名]
# bd = 0 and highlightthickness = 0 make sure that there isn't a border around the screen
canvas = Tkinter.Canvas(top, width=500, height=400, bd=0, highlightthickness=0)
# Tells the canvas to size itself according to the width and height parameters we pass in line 17
canvas.pack()
# Tells Tkinter to initialize itself
top.update()
# Creates an object named 'paddle' of the Paddle class that we created in Paddle.py
paddle = Paddle(canvas, 'blue')
# Creates an object named 'ball' of the Ball class that we created in Ball.py
ball = Ball(canvas, paddle, 'red')
current_score = 0
# Creates the label for the score
score = Tkinter.Label(canvas, text= ball.score())
# Displays that window
canvas.create_window(10, 20, window=score, anchor='w')
# Tells the canvas to not loop through the listed command until the user close the window
while 1:
# Calls the draw function on the ball as long as hit_bottom is False
ball.draw()
# Calls the draw function on the paddle as long as hit_bottom is False
paddle.draw()
# Updates the score