本文整理汇总了Python中ball.Ball.draw_shadow方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.draw_shadow方法的具体用法?Python Ball.draw_shadow怎么用?Python Ball.draw_shadow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ball.Ball
的用法示例。
在下文中一共展示了Ball.draw_shadow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import draw_shadow [as 别名]
class Game(object):
"""Main program"""
def __init__(self):
#Initialize pygame and window
pygame.init()
self.screen_width, self.screen_height = 400, 600
self.screen = pygame.display.set_mode((self.screen_width, self.screen_height), 0, 32)
self.screen.fill(blue)
pygame.display.update()
#Clock
self.clock = pygame.time.Clock()
#Bricks
self.blocks = list()
for w in range(1,self.screen_width,50):
for h in range(23, 198, 22):
self.blocks.append(Block(self.screen_width, self.screen_height, w, h, orange, blue_shadow))
#Paddle
self.paddle = Paddle(self.screen_width, self.screen_height, purple, blue_shadow)
#Ball
self.ball = Ball(self.screen_width, self.screen_height, green, blue_shadow)
def update(self):
self.clock.tick(game_speed)
self.paddle.update()
self.ball.update(self.paddle)
def draw(self):
#Redraw Background
self.screen.fill(blue)
for block in self.blocks:
block.draw_shadow(self.screen)
self.ball.draw_shadow(self.screen)
self.paddle.draw_shadow(self.screen)
for block in self.blocks:
block.draw(self.screen)
self.ball.draw(self.screen)
self.paddle.draw(self.screen)
def new_game(self):
self.game_over = False
self.round = 0
self.play()
def new_round(self):
pass
def play(self):
while not self.game_over:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
self.ball.serve()
if event.key == pygame.K_LEFT:
self.paddle.x_vel = -4
elif event.key == pygame.K_RIGHT:
self.paddle.x_vel = 4
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT and self.paddle.x_vel < 0:
self.paddle.x_vel = 0
if event.key == pygame.K_RIGHT and self.paddle.x_vel > 0:
self.paddle.x_vel = 0
self.update()
self.draw()
pygame.display.update()