本文整理汇总了Python中ball.Ball.park_at方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.park_at方法的具体用法?Python Ball.park_at怎么用?Python Ball.park_at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ball.Ball
的用法示例。
在下文中一共展示了Ball.park_at方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PongPlayers
# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import park_at [as 别名]
class PongPlayers(NetworkSingletonActor):
def birth(self):
self.players = []
self.ball_location = -1
self.ball = Ball()
PictureInPictureManager().setball(self.ball)
def add(self, player):
self.players.append(player)
if self.ball_location == -1:
self.ball_location = 0
player.incoming(self.ball)
self.playerchange()
def leaving(self):
if len(self.players) == 0:
self.ball_location = -1
self.ball.park_at(here())
return
self.ball_location = (self.ball_location + 1) % len(self.players)
self.players[self.ball_location].incoming(self.ball)
def current_player(self):
if self.ball_location >= 0 and self.ball_location < len(self.players):
return self.players[self.ball_location]
return None
def remove(self, actor):
ball_on_dying_theatre = False
if actor in self.players:
if self.ball_location >= 0 and self.ball_location < len(self.players):
ball_on_dying_theatre = self.players[self.ball_location] == actor
self.players.remove(actor)
if ball_on_dying_theatre:
self.leaving()
self.playerchange()
def getall(self):
return self.players
def tellall(self, theatres):
for player in self.players:
player.availabletheatres(theatres)
def actorlost(self, actor, message):
self.remove(actor)
def playerchange(self):
PictureInPictureManager().players_are(self.players)
def theatreclosing(self):
migrate_or_die()