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


Python enemy.Enemy类代码示例

本文整理汇总了Python中enemy.Enemy的典型用法代码示例。如果您正苦于以下问题:Python Enemy类的具体用法?Python Enemy怎么用?Python Enemy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self, g, pos):
     Enemy.__init__(self, g, pos, 'drop')
     self.frm1 = g.images['inventory'][0].subsurface((0 * 32, 8 * 32, 32, 32))
     self.frm2 = g.images['inventory'][0].subsurface((1 * 32, 8 * 32, 32, 32))
     self.frm3 = g.images['inventory'][0].subsurface((2 * 32, 8 * 32, 32, 32))
     self.frm4 = g.images['inventory'][0].subsurface((3 * 32, 8 * 32, 32, 32))
     self.timer = random.randint(0, 50)
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:7,代码来源:drip.py

示例2: create_enemy

def create_enemy(game_settings, screen, enemies, enemy_number, row_number):
    enemy = Enemy(game_settings, screen)
    enemy_width = enemy.rect.width
    enemy.x = enemy_width + 2 * enemy_width * enemy_number
    enemy.rect.x = enemy.x
    enemy.rect.y = enemy.rect.height + 2 * enemy.rect.height * row_number
    enemies.add(enemy)
开发者ID:j-pk,项目名称:Rebel-Defender,代码行数:7,代码来源:game_functions.py

示例3: test_distance

 def test_distance(self):
     e = Enemy(self.road, 100, "red", self.state)
     e.posx = -20
     e.posy = -20
     x = 300
     y = 400
     self.assertEqual(gameState.distance(e, x, y), 500)
开发者ID:dolgihnatasha,项目名称:TowerDefense,代码行数:7,代码来源:test.py

示例4: after_move

    def after_move(self):
        Enemy.after_move(self)

        nextcell = self.level.get_neighbour(self.pos, self.move_dir)
        if self.level.object_can_enter(
                nextcell) and not self.level.get_solid_sprites_in(nextcell):
            self.to_move = 1
开发者ID:saltire,项目名称:roverchip,代码行数:7,代码来源:sentry.py

示例5: spawn_monster

 def spawn_monster(self, antal, pref=None, lila=None):
     """Spawnar vanliga mobs.
     
     @param antal: Hur många mobs
     @param pref: Vilken typ 
     
     """
     x = self.SCREEN_WIDTH
     all_monsters = [os.path.join('images','dygaddaa.png'),
                     os.path.join('images','taggfisk.png'),
                     os.path.join('images','monsterfisk.png'),
                     os.path.join('images','taggfisk-blue.png'),
                     os.path.join('images','taggfisk-green.png')]
     if pref:
         img = all_monsters[pref]
     elif lila:
         img = os.path.join('images','taggfisk-lila.png')
     else:
         img = random.choice(all_monsters)
     for i in range(antal):
         random_y = random.randint(0,self.SCREEN_HEIGHT-100)
         temp = Enemy(screen=self.screen,
                                img_filename=img,
                                init_position=(x, random_y) 
                                )
         temp.set_speed(random.randint(-7, -3))
         self.enemy_grp.add(temp)
         # Nästa fiende lite åt sidan
         x += 60         
开发者ID:iingemar,项目名称:fishwarz,代码行数:29,代码来源:game.py

示例6: EnemyTests

class EnemyTests(unittest.TestCase):

    def setUp(self):
        self.enemy = Enemy()

    def test_is_alive(self):
        self.assertEqual(self.enemy.is_alive(), True)

    def test_get_health(self):
        self.assertEqual(self.enemy.get_health(), 100)

    def test_get_mana(self):
        self.assertEqual(self.enemy.get_mana(), 100)

    def test_can_cast(self):
        self.assertEqual(self.enemy.can_cast(), True)

    def test_take_healing(self):
        e = Enemy(80, 100, 20)
        e.take_healing(15)
        self.assertEqual(e.get_health(), 95)

    def test_take_mana(self):
        e = Enemy(100, 80, 20)
        e.take_mana(15)
        self.assertEqual(e.get_mana(), 95)
开发者ID:Antoniy7,项目名称:Dungeon,代码行数:26,代码来源:enemy_test.py

示例7: testCleanup

 def testCleanup(self):
     board = Board(5, 5)
     player = Player()
     enemy_one = Enemy()
     enemy_one.destroyed = True
     enemy_two  = Enemy()
     bullet_one = Bullet()
     bullet_one.destroyed = True
     bullet_two = Bullet()
     bullet_two.destroyed = True
     bullet_three = Bullet()
     bonus_one = Bonus()
     bonus_one.destroyed = True
     bonus_two = Bonus()
     board.rows[0][0] = player
     board.rows[1][1] = enemy_one
     board.rows[2][2] = enemy_two
     board.rows[3][3] = bullet_one
     board.rows[4][4] = bullet_two
     board.rows[1][3] = bullet_three
     board.rows[2][0] = bonus_one
     board.rows[3][4] = bonus_two
     board.cleanup()
     self.assertEqual(board.rows[0][0], player)
     self.assertEqual(board.rows[2][2], enemy_two)
     self.assertEqual(board.rows[1][3], bullet_three)
     self.assertEqual(board.rows[3][4], bonus_two)
     self.assertIsNone(board.rows[1][1])
     self.assertIsNone(board.rows[3][3])
     self.assertIsNone(board.rows[4][4])
     self.assertIsNone(board.rows[2][0])
开发者ID:elenaod,项目名称:PythonScrollingShooter,代码行数:31,代码来源:test_board.py

示例8: schedule_enemy

 def schedule_enemy(self, dt):
     enemy = Enemy()
     enemy.center = (self.width - 20, self.center_y)
     self.add_widget(enemy)
     (fx, fy) = self.x, random.randint(self.y, self.top)
     enemy.animate(fx, fy, self)
     self.enemies.append(enemy)
开发者ID:c-muller,项目名称:scramble-clone,代码行数:7,代码来源:main.py

示例9: __init__

	def __init__(self, game, xStart = 0, yStart = 0, zStart = 0):
		models = MODELS_PATH + "SwarmCraft"
		anims = None
		Enemy.__init__(self, models, anims, "**/enemyCollisionSphere", game, xStart, yStart, zStart)
		
		self.maxSpeed = 5
		self.randomMovementMax = random.randint(7 * 7, 10 * 7)
开发者ID:tom-anesta,项目名称:team-conventions,代码行数:7,代码来源:rushEnemy.py

示例10: update

	def update(self, time):
		newTime = time * 1000000
		
		if math.floor(newTime % self.randomMovementMax) == 0:
			self.rush(self.game.player)
		
		Enemy.update(self, time)
开发者ID:tom-anesta,项目名称:team-conventions,代码行数:7,代码来源:rushEnemy.py

示例11: __init__

 def __init__(self, g, pos):
     Enemy.__init__(self, g, pos, 'monster2')
     hitSoundFile = os.path.join("effects",  "critter4.wav")
     self.birdhit = pygame.mixer.Sound(hitSoundFile)
     self.health = 3
     self.rect.height = 16
     self.changedDirLastTick = 0
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:7,代码来源:monster2.py

示例12: setUp

 def setUp(self):
     self.enemy_alive = Enemy(100, 0, 20)
     self.enemy_1fourthalive = Enemy(25, 0, 20)
     self.enemy_dead = Enemy(0, 50, 20)
     self.enemy_halfalive = Enemy(50, 0, 20)
     self.enemy_3fourthsalive = Enemy(75, 5, 60)
     self.knife = Weapon("knife", 20)
     self.spell = Spell("Fireball", 30, 50, 2)
开发者ID:anedelcheva,项目名称:Game-Dungeons-and-Pythons,代码行数:8,代码来源:enemy_test.py

示例13: __init__

	def __init__(self, game, player, xStart = 0, yStart = 0, zStart = 0):
		models = MODELS_PATH + "HovercraftOne"
		anims = None
		Enemy.__init__(self, models, anims, "**/enemyCollisionSphere", game, xStart, yStart, zStart)
		
		self.health = 10
		self.pointValue = 1
		self.player = player
开发者ID:tom-anesta,项目名称:team-conventions,代码行数:8,代码来源:droneEnemy.py

示例14: __init__

	def __init__(self, game, xStart = 0, yStart = 0, zStart = 0):
		models = MODELS_PATH + "TankyHovercraft"
		anims = None
		Enemy.__init__(self, models, anims, "**/enemyCollisionSphere", game, xStart, yStart, zStart)
		self.cooldownLength = random.randint(6, 8)
		self.cooldownLeft = self.cooldownLength
		self.preferedDistanceFromPlayer = random.randint(20, 40)
		self.clockwise = random.choice((True, False))
开发者ID:tom-anesta,项目名称:team-conventions,代码行数:8,代码来源:shootingEnemy.py

示例15: __init__

 def __init__(self, g, pos):
     Enemy.__init__(self, g, pos, 'bugs')
     self.frm1 = g.images['inventory'][0].subsurface((7 * 32, 7 * 32, 32, 32))
     self.frm2 = g.images['inventory'][0].subsurface((6 * 32, 7 * 32, 32, 32))
     self.rect.y += 2
     self.rect.x += random.randint(-4,4)
     self.flying = 0
     self.vecx = random.randint(-5,5)
     self.vecy = 0
开发者ID:torleif,项目名称:Dystopian-Future,代码行数:9,代码来源:bugs.py


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