当前位置: 首页>>代码示例>>Python>>正文


Python Ball.park_at方法代码示例

本文整理汇总了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()
开发者ID:fredvdd,项目名称:Swan,代码行数:55,代码来源:pongmanager.py


注:本文中的ball.Ball.park_at方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。