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


Python Tile.isEmpty方法代码示例

本文整理汇总了Python中tile.Tile.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Python Tile.isEmpty方法的具体用法?Python Tile.isEmpty怎么用?Python Tile.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tile.Tile的用法示例。


在下文中一共展示了Tile.isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: detonateBomb

# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import isEmpty [as 别名]
    def detonateBomb(self):
        x, y, z = self.level.bombQueue.pop(0)
        if (self.tileAt(x,y) == Tile.Bomberman):
            self.popTileAt(x,y)
            self.popTileAt(x,y)
            self.setTileAt(x,y,Tile.Bomberman)
        else:
            self.popTileAt(x,y)

        flashList = []
        popList = []
        killedEnemies = [[] for i in range(self.level.bomberman.rangeOfBombs)]

        # NORTH
        for i in range(1,self.level.bomberman.rangeOfBombs+1):
            modY = y + i
            if (modY < constant.BOARD_HEIGHT-1):
                northTile = self.tileAt(x,modY)
                if (northTile == Tile.Concrete or northTile == Tile.Bomb):
                    break
                if (Tile.isEmpty(northTile)):
                    flashList.append((x,modY))
                if (northTile == Tile.Brick):
                    popList.append((x,modY))
                    break
                if (Tile.isEnemy(northTile)):
                    killedEnemies[i-1].append(northTile)
                    self.killEnemy(x, modY)
                if (Tile.isBomberman(northTile) and not self.level.bomberman.invincible):
                    self.death()
                    break
                if (Tile.isPowerup(northTile) or Tile.isExit(northTile)):
                    self.level.setChaos()
                    break

        # SOUTH
        for i in range(1,self.level.bomberman.rangeOfBombs+1):
            modY = y - i
            if (modY < constant.BOARD_HEIGHT-1):
                southTile = self.tileAt(x,modY)
                if (southTile == Tile.Concrete or southTile == Tile.Bomb):
                    break
                if (Tile.isEmpty(southTile)):
                    flashList.append((x,modY))
                if (southTile == Tile.Brick):
                    popList.append((x,modY))
                    break
                if (Tile.isEnemy(southTile)):
                    killedEnemies[i-1].append(southTile)
                    self.killEnemy(x, modY)
                if (Tile.isBomberman(southTile) and not self.level.bomberman.invincible):
                    self.death()
                    break
                if (Tile.isPowerup(southTile) or Tile.isExit(southTile)):
                    self.level.setChaos()
                    break

        # EAST
        for i in range(1,self.level.bomberman.rangeOfBombs+1):
            modX = x + i
            if (modX < constant.BOARD_WIDTH-1):
                eastTile = self.tileAt(modX,y)
                if (eastTile == Tile.Concrete or eastTile == Tile.Bomb):
                    break
                if (Tile.isEmpty(eastTile)):
                    flashList.append((modX,y))
                if (eastTile == Tile.Brick):
                    popList.append((modX,y))
                    break
                if (Tile.isEnemy(eastTile)):
                    killedEnemies[i-1].append(eastTile)
                    self.killEnemy(modX, y)
                if (Tile.isBomberman(eastTile) and not self.level.bomberman.invincible):
                    self.death()
                    break
                if (Tile.isPowerup(eastTile) or Tile.isExit(eastTile)):
                    self.level.setChaos()
                    break

        # WEST
        for i in range(1,self.level.bomberman.rangeOfBombs+1):
            modX = x - i
            if (modX < constant.BOARD_WIDTH-1):
                westTile = self.tileAt(modX,y)
                if (westTile == Tile.Concrete or westTile == Tile.Bomb):
                    break
                if (Tile.isEmpty(westTile)):
                    flashList.append((modX,y))
                if (westTile == Tile.Brick):
                    popList.append((modX,y))
                    break
                if (Tile.isEnemy(westTile)):
                    killedEnemies[i-1].append(westTile)
                    self.killEnemy(modX, y)
                if (Tile.isBomberman(westTile) and not self.level.bomberman.invincible):
                    self.death()
                if (Tile.isPowerup(westTile) or Tile.isExit(westTile)):
                    self.level.setChaos()
                    break

#.........这里部分代码省略.........
开发者ID:michaelchum,项目名称:bomberman-py,代码行数:103,代码来源:board.py


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