本文整理汇总了Python中level.Level.map方法的典型用法代码示例。如果您正苦于以下问题:Python Level.map方法的具体用法?Python Level.map怎么用?Python Level.map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类level.Level
的用法示例。
在下文中一共展示了Level.map方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import map [as 别名]
#.........这里部分代码省略.........
if game_started is True:
self.ball.move(ball_direction_y)
self.ball.move(ball_direction_x)
# ball/boundary collision control
# left / right of border
if self.ball.left <= self.window_border_left:
ball_direction_x = self.ball.direction.RIGHT
if self.ball.right >= self.window_border_right:
ball_direction_x = self.ball.direction.LEFT
if self.ball.top <= self.window_border_top:
ball_direction_y = self.ball.direction.DOWN
# bottom of border
if self.ball.bottom >= self.window_border_bottom:
deaths += 1
game_started = False
# ball/paddle collision control
if self.ball.bottom + self.ball.velocity()/2 >= self.paddle.top and self.ball.top < self.paddle.bottom \
and ball_direction_y == self.ball.direction.DOWN:
if self.ball.left >= self.paddle.left and self.ball.right <= self.paddle.right:
ball_direction_y = self.ball.direction.opposite(ball_direction_y)
if self.ball.left >= self.paddle.left \
and self.ball.right <= self.paddle.left + self.paddle_divert_range \
and ball_direction_x == self.ball.direction.RIGHT \
or self.ball.right <= self.paddle.right \
and self.ball.left >= self.paddle.right - self.paddle_divert_range \
and ball_direction_x == self.ball.direction.LEFT:
ball_direction_x = self.ball.direction.opposite(ball_direction_x)
# ball/block collision control
for block in self.level.map():
# go to the next level once map is cleared
if self.level.cleared():
game_started = False
block_rect = pygame.Rect(block[1])
if self.ball.top >= block_rect.top \
and self.ball.bottom <= block_rect.bottom \
and self.ball.left - self.ball.velocity() <= block_rect.right < self.ball.right:
ball_direction_x = self.ball.direction.opposite(ball_direction_x)
self.level.hit(block)
score += 1
if score % 4 == 0 and level != 5:
level += 1
self.ball.velocity(self.ball.velocity() + 2)
if self.ball.top >= block_rect.top \
and self.ball.bottom <= block_rect.bottom \
and self.ball.right + self.ball.velocity() >= block_rect.left > self.ball.left:
ball_direction_x = self.ball.direction.opposite(ball_direction_x)
self.level.hit(block)
score += 1
if score % 4 == 0 and level != 3:
level += 1
self.ball.velocity(self.ball.velocity() + 2)
# bottom of block, top of ball
if self.ball.right <= block_rect.right \