本文整理汇总了Python中tile.Tile.isEnemy方法的典型用法代码示例。如果您正苦于以下问题:Python Tile.isEnemy方法的具体用法?Python Tile.isEnemy怎么用?Python Tile.isEnemy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tile.Tile
的用法示例。
在下文中一共展示了Tile.isEnemy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tryMove
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import isEnemy [as 别名]
def tryMove(self, newX, newY):
if (self.isPaused):
return False
elif (not self.level.bomberman.canMove):
return False
elif (self.level.bomberman.wallPass and self.level.bomberman.bombPass):
if (self.tileAt(newX,newY) == Tile.Concrete):
return False
elif (self.level.bomberman.wallPass):
if (self.tileAt(newX,newY) == Tile.Concrete or self.tileAt(newX,newY) == Tile.Bomb):
return False
elif (self.level.bomberman.bombPass):
if (self.tileAt(newX,newY) == Tile.Concrete or self.tileAt(newX,newY) == Tile.Brick):
return False
elif (self.tileAt(newX,newY) == Tile.Concrete or self.tileAt(newX,newY) == Tile.Brick or self.tileAt(newX,newY) == Tile.Bomb):
return False
elif Tile.isEnemy(self.tileAt(newX,newY)):
self.death()
return False
# Pop level at current pos
self.popTileAt(self.level.bomberman.curX,self.level.bomberman.curY)
# Compute new position
self.level.bomberman.curX = newX
self.level.bomberman.curY = newY
# Check if new pos is powerup
if (self.tileAt(self.level.bomberman.curX,self.level.bomberman.curY) == Tile.Powerup):
self.popTileAt(newX, newY)
self.level.gainPowerUp()
# Check if new pos is exit
if ((self.tileAt(self.level.bomberman.curX,self.level.bomberman.curY) == Tile.Exit) and self.level.numberEnemies == 0):
self.exit()
return # IMPORTANT
# Set level to new pos
self.setTileAt(self.level.bomberman.curX,self.level.bomberman.curY,Tile.Bomberman)
# Limit level move speed
self.bombermanTriggerCanMove()
self.globalTimer.singleShot(self.level.bomberman.speed, self.bombermanTriggerCanMove)
return True
示例2: detonateBomb
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import isEnemy [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
#.........这里部分代码省略.........