def initEnemyTanks(self): top = 100 # loop to create enemy tanks for i in range(ENEMY_TANK_COUNT): left = nprandom.randint(0, 600) speed = nprandom.randint(1, 4) enemyTank = EnemyTank(top, left, speed) MainGame.enemyTanksList.append(enemyTank)
def randDirection(self): num = nprandom.randint(1, 4) if num == 1: return 'U' elif num == 2: return 'D' elif num == 3: return 'L' elif num == 4: return 'R'
def __init__(self, top, left, speed): super().__init__() self.enemyTank = self.enemyTanksImgs.get(self.direction) self.direction = self.randDirection() self.rect = self.enemyTank.get_rect() self.speed = ENEMY_TANK_SPEED[nprandom.randint(0, 4)] self.rect.left = left self.rect.top = top self.movement = True self.step = ENEMY_TANK_STEP
def shoot(self): if nprandom.randint(1, 200) < 10: return Bullet(self)