本文整理汇总了Python中Player.attack方法的典型用法代码示例。如果您正苦于以下问题:Python Player.attack方法的具体用法?Python Player.attack怎么用?Python Player.attack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.attack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_playerAttack
# 需要导入模块: import Player [as 别名]
# 或者: from Player import attack [as 别名]
def test_playerAttack(self):
arni = Player("Arni")
villi = Player("Villi")
pre = Presets()
emptyArray = []
arni.mainCard = pre.gc("Charizard")
villi.mainCard = pre.gc("Bulbasaur")
self.assertTrue(isinstance(arni.attack(2, villi, emptyArray), bool))
示例2: __init__
# 需要导入模块: import Player [as 别名]
# 或者: from Player import attack [as 别名]
class GameMap:
def __init__(self, parent, gen):
global MAP_WIDTH
global MAP_HEIGHT
global CELL_SIZE
global INIT_SPAWN_RATE
self.size = width, height = MAP_WIDTH, MAP_HEIGHT
self.parent = parent
self.gameover = False
self.gen = gen
self.bgcolor = (135, 206, 250)
self.mapcolor = (154, 205, 50)
self.screen = pygame.display.get_surface()
self.basemap = pygame.Surface(self.size, pygame.SRCALPHA)
self.basemap.fill(self.mapcolor)
self.hud = hud(self, parent)
self.item_timer = 0
self.timer = 0
self.progress = 0.0
self.cloud_timer = 0
self.feature_timer = 0
self.player = Player(self)
self.sprite_list = pygame.sprite.Group()
#self.sprite_list.add(self.player)
self.enemy_list = []
self.dead_list = []
self.item_list = []
self.feature_list = []
self.generate_feature("parallax_cloud_back")
self.generate_feature("parallax_cloud_back")
self.generation = gen
self.spawnrate = INIT_SPAWN_RATE - gen/10.0
if self.spawnrate < 0.5:
self.spawnrate = 0.5
def render(self):
self.screen.fill(self.bgcolor)
self.screen.blit(self.basemap, [0, 180])
#self.sprite_list.draw(self.screen)
self.player.render_sprite()
for en in self.enemy_list:
en.render_sprite()
for it in self.item_list:
it.render_sprite()
for feat in self.feature_list:
feat.render_sprite()
self.hud.render_sprite()
def update(self, deltat):
global INIT_SPAWN_RATE
global INIT_ITEM_RATE
global SPAWN_CLOUD
global SPAWN_FEATURES
self.timer += deltat/1000.0
self.item_timer += deltat/1000.0
self.cloud_timer += deltat/1000.0
self.feature_timer += deltat/1000.0
self.progress += deltat/1000.0
if self.gameover == True:
return
self.player.update(deltat)
for en in self.enemy_list:
en.update(deltat)
dist = get_dist_pe(self.player, en)
if (self.player.is_attacking and dist < self.player.atk_range):
en.get_hit(self.player)
if (en.dead == True):
self.enemy_list.remove(en)
self.sprite_list.remove(en)
if (dist < 40):
self.gameover = True
for it in self.item_list:
it.update(deltat)
dist = get_dist_pe(self.player, it)
if (dist < 40):
it.dead = True
self.parent.next_items.append(it.type)
if (it.dead == True):
self.item_list.remove(it)
#.........这里部分代码省略.........