def get_bosses(): itemlist = [] bosslist = [] itemlist.append(Item("Twisted Bow",20000000)) itemlist.append(Item("Elder Maul",2000000)) bosslist.append(Boss('Chambers of Xeric', itemlist).jsoned()) itemlist=[] itemlist.append(Item("Scythe of Vitur",20000000)) itemlist.append(Item("Ghrazi Rapier",2000000)) bosslist.append(Boss('Theater of Blood', itemlist).jsoned()) itemlist=[] itemlist.append(Item("Pegasian Crystal",20000000)) itemlist.append(Item("Primordial Crystal",2000000)) bosslist.append(Boss('Cerberus', itemlist).jsoned()) itemlist=[] itemlist.append(Item("Smoke Battlestaff",20000000)) itemlist.append(Item("Amulet",2000000)) bosslist.append(Boss('Thermonuclear Smoke Devil', itemlist).jsoned()) itemlist=[] itemlist.append(Item("Hydra Leather",20000000)) itemlist.append(Item("Hydras Claw",2000000)) bosslist.append(Boss('Alchemical Hydra', itemlist).jsoned()) sim = Simulator() print({'bosses' : bosslist}, file=sys.stderr) total = 0 trials=1 #for i in range(trials): print(sim.simulate(bosslist[0]['items'])) # total+=i1 #print(total/trials) return {'bosses' : bosslist}
def enter(): global boss_exist, middle_boss_exist boss_exist = 0 middle_boss_exist = 0 global boss_gauge boss_gauge = 0 global hero global cursor global boss global boss_right_arm global boss_left_arm global enemy_genarate global middle_boss map = Map() cursor = Cursor() boss = Boss() boss_right_arm = Boss_right_arm() boss_left_arm = Boss_left_arm() middle_boss = Middle_boss() hero = Hero() hide_cursor() game_world.add_object(map, 0) enemy_genarate = Enemy_genarate() game_world.add_object(hero, 1) game_world.add_object(cursor, 4) game_world.add_object(enemy_genarate, 0)
def create_boss(ai_settings, screen, bosses): boss = Boss(ai_settings, screen) screen_rect = screen.get_rect() boss.rect.x = screen_rect.centerx boss.rect.y = 0 boss.shoot() bosses.add(boss)
def __init__(self): self.width = 1400 self.screenWidth = 170 self.height = 45 self.grid = [[' ' for i in range(self.width)] for j in range(self.height)] self.getch = getInput._getChUnix() self.bricks = [] self.enemies = [] self.smartEnemies = [] self.bullets = [] self.bridge = Bridge() self.boss = Boss() self.coins = [] self.bossBullets = [] self.springs = [] self.black = '\u001b[30;1m' self.red = '\u001b[31;1m' self.green = '\u001b[32;1m' self.yellow = '\u001b[33;1m' self.blue = '\u001b[34;1m' self.magenta = '\u001b[35;1m' self.cyan = '\u001b[36;1m' self.white = '\u001b[37;1m' self.reset = '\u001b[0m'
def main(): print('1 - Add Employee') print('2 - Add Boss') print('3 - Print employees') print('4 - Remove employee by index') print('5 - Save company to file') print('6 - Read company to file') print('7 - Exit') company = Company() while True: command = input('Enter command: ') if command == '1': emp = Employee() company.add_employee(emp.read_from_console()) elif command == '2': boss = Boss() company.add_employee(boss.read_from_console()) elif command == '3': print(company) elif command == '4': index = int(input('Enter index: ')) del company.employees[index] elif command == '5': fname = input('Enter file name: ') company.write_to_file(fname) elif command == '6': fname = input('Enter file name: ') company = Company.read_from_file(fname) elif command == '7': break else: print('Wrong command!')
def create_object(ch, x, y): if ch in ['1', '2', '3', '4', '5', '6']: obj = Jelly(ord(ch) - ord('1'), x, y) gfw.world.add(gfw.layer.item, obj) #print('creating Jelly', x, y) elif ch in ['O', 'P']: dy = 1 if ch == 'O' else 3 #4 y -= dy * BLOCK_SIZE // 2 x -= BLOCK_SIZE // 2 obj = Platform(ord(ch) - ord('O'), x, y) gfw.world.add(gfw.layer.platform, obj) #print('creating Platform', x, y) elif ch in ['B']: e = Boss(x, y - 10) gfw.world.add(gfw.layer.boss, e) else: if ch == 'X': y -= 105 elif ch == 'Y': y -= 33 elif ch == 'Z': y += 10 ao = factory.create(ch, x, y) if ao is None: global ignore_char_map if ch not in ignore_char_map: print("Error? I don't know about: '%s'" % ch) ignore_char_map |= {ch} return l, b, r, t = ao.get_bb() ao.pass_wh(r - l, t - b) gfw.world.add(gfw.layer.enemy, ao)
def get_boss(): itemlist = [] itemlist.append(Item("Pegasian Crystal",30000000)) itemlist.append(Item("Eternal Crystal",2654963)) boss = Boss('Cerberus', itemlist) print(boss.jsoned(), file=sys.stderr) return boss.jsoned()
def move(self, movement, grid): new_dragon_cords = {} for i in self.__dragon_coordinates: new_dragon_cords[i + movement[0]] = [] for j in self.__dragon_coordinates[i]: new_dragon_cords[i + movement[0]].append(j + movement[1]) for i in new_dragon_cords: for j in new_dragon_cords[i]: if grid[i][j].blocking == 1: return li = list(self.__dragon_coordinates.keys()) li.sort() self.upper_coordinate = li[0] for i in self.__dragon_coordinates: for j in self.__dragon_coordinates[i]: grid[i][j] = Playarea() self.__dragon_coordinates.clear() cnt1 = 0 cnt2 = 0 for i in new_dragon_cords: self.__dragon_coordinates[i] = [] cnt2 = 0 for j in new_dragon_cords[i]: grid[i][j] = Boss(self.__dragon_disp[cnt1][cnt2]) self.__dragon_coordinates[i].append(j) cnt2 += 1 cnt1 += 1 return
def __restartCurrentLevelOver(self, instance): if (self.gameOverSound.state == "play"): self.gameOverSound.stop() if (self.gameWinSound.state == "play"): self.gameWinSound.stop() self.player = Player() self.player.pos = [200, 10] self.lobo = Boss() self.niveis[self.nivelCorrente] = None self.niveis[self.nivelCorrente] = Nivel1( player=self.player, backgroundImage="./images/fundo.png", boss=self.lobo) self.niveis[0].soundOn = self.soundOn self.lobo.pos = [self.niveis[0].tamanhoFase / 3, 10] self.add_widget(self.niveis[0]) self.add_widget(self.player) self.add_widget(self.lobo) self.add_widget(self.gameMenu) self.remove_widget(self.gameOverMenu) self.gamePause = False
def __init__(self): #Créer le constructeur de la classe self.is_playing = False #Dire que le jeu n'as pas commencé self.end_game = False #Signaler que le jeu n'est pas terminé self.all_players = pygame.sprite.Group() #Créer le groupe du joueur self.player = Player(self) #Ajouter le joueur au jeu self.all_players.add(self.player) #Ajouter le joueur au groupe self.all_monsters = pygame.sprite.Group( ) #Créer le groupe des monstres self.pressed = { } #Définir le dictionnaire pour savoir si des touches sont pressées self.comet_event = CometFallEvent(self) #Stocker la classe des comètes self.score = 0 #Définir la score initial self.font = pygame.font.Font("assets/Righteous-Regular.ttf", 25) # Créer la police du texte du score self.sound_manager = SoundManager() #Stocker la classe des sons self.all_boss = pygame.sprite.Group() # Créer le groupe du monstre self.boss = Boss(self) # Stocker la classe du boss self.projectile = True self.event = 1 self.paused = False self.end_text = self.font.render( "Congratulations ! You have completed the game !!!", 1, (0, 0, 0)) # Créer le texte des vies globales self.general_data = {} self.infinite = False self.recovback()
def create_boss(ai_settings, screen, boss): """create an alien and place it in the row""" boss = Boss(ai_settings, screen) boss_width = boss.rect.width boss.x = boss_width boss.rect.x = boss.x boss.rect.y = boss.rect.height boss.add(boss)
def create_boss_group(ai_setting, screen, bossGroup): """创建一群僵尸boss""" if ai_setting.boss_time > 0: boss = Boss(ai_setting, screen) y_number = int((600 - boss.rect.height) / boss.rect.height) if len(bossGroup) == 0: boss = Boss(ai_setting, screen) bossGroup.add(boss) else: for m in range(2): for n in range(y_number): boss = Boss(ai_setting, screen) boss.x = 1000 + (100 * m) boss.rect.y = (n + 1) * boss.rect.height bossGroup.add(boss) ai_setting.boss_time = 0
def __init__(self): # 初始化 pygame pygame.init() # 初始化時間,遊戲幀數為每秒60幀 self.mainClock = pygame.time.Clock() self.mainClock.tick(60) self.tick = 0 # 初始化「繪圖」、「聲音」、「主角」 self.renderer = Renderer() self.character = Character() self.sound = Sound() self.bgm = Sound() '''遊戲參數初始化設定''' self.pause = False # 可控制遊戲暫停 self.quit = False # 可退出當前遊戲 self.pause_button = 0 # 遊戲暫停選單按鍵 self.game_over_button = 0 # 遊戲死亡選單按鍵 '''遊戲參數初始化設定結束''' '''遊戲精靈群組初始化''' self.allsprite = pygame.sprite.Group() # 精靈群組的總群組 self.bulletsprite = pygame.sprite.Group() # 子彈群組 self.bricksprite = pygame.sprite.Group() # 子彈邊界群組 self.bosssprite = pygame.sprite.Group() # 魔王群組 self.score_sprite = pygame.sprite.Group() self.shoes_sprite = pygame.sprite.Group() self.heart_sprite = pygame.sprite.Group() self.bonus_lst = [ self.score_sprite, self.shoes_sprite, self.heart_sprite ] # 突發class清單 self.direction = 0 self.num = 0 self.speed_adjust = 0 self.map_changex = 0 self.map_changey = 0 self.speed_up = False self.speed_up_time = 0 # 魔王加群組 self.boss = Boss() # boss = Boss(const.screen_width // 2 + self.map_changex, const.screen_height // 2 + self.map_changey) self.bosssprite.add(self.boss) '''遊戲精靈群組初始化結束''' self.volume_dct = { "v_0": pygame.image.load("images/volume/volume.png"), "v_1": pygame.image.load("images/volume/volume5.png"), "v_2": pygame.image.load("images/volume/volume4.png"), "v_3": pygame.image.load("images/volume/volume3.png"), "v_4": pygame.image.load("images/volume/volume2.png"), "v_5": pygame.image.load("images/volume/volume1.png"), "v_6": pygame.image.load("images/volume/volume0.png") } self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
def fillBricks(self, num): array = [] array2 = [] if num == 1: a = 0 for i in range(0, 18, 3): for j in range(0, 144, 8): stren = random.randint(1, 5) hl = int(j / 8) whbrick = np.random.choice(2, 1, p=[0.9, 0.1]) if whbrick: stren = 3 if (hl == a or hl == a + 1 or hl == 17 - a or hl == 17 - a - 1) and int(i / 3) != 5: stren = 6 whbrick = 0 array.append( Brick(9 + i, 30 + j, 3, 8, 0, 0, stren, whbrick)) if (stren == 3 or stren == 4): array2.append( PowerUp(9 + i, 30 + j, 1, 1, 0, 0, random.choice(POWERUPS))) a += 2 if num == 2: a = 10 for i in range(0, 18, 3): for j in range(0, 144, 8): stren = random.randint(1, 5) hl = int(j / 8) whbrick = np.random.choice(2, 1, p=[0.9, 0.1]) if whbrick: stren = 3 if (hl == a or hl == a + 1 or hl == 17 - a or hl == 17 - a - 1) and int(i / 3) != 0: stren = 6 whbrick = 0 if not ((int(i / 3) == 0 and int(j / 8) == 0) or (int(i / 3) == 0 and int(j / 8) == 17)): array.append( Brick(9 + i, 30 + j, 3, 8, 0, 0, stren, whbrick)) if (stren == 3 or stren == 4): array2.append( PowerUp(9 + i, 30 + j, 1, 1, 0, 0, random.choice(POWERUPS))) a -= 2 if num == 3: array.append(Boss(0, int(FRAMEWIDTH / 2), 7, 33, 0, 1, 20, 0)) for i in range(9, 18, 3): for j in range(0, 144, 8): stren = random.randint(1, 5) if stren == 5: array.append(Brick(9 + i, 30 + j, 3, 8, 0, 0, stren, 0)) return array, array2
def insert(self, grid): i2 = 0 j2 = 0 for i in self.__dragon_coordinates: j2 = 0 for j in self.__dragon_coordinates[i]: grid[i][j] = Boss(self.__dragon_disp[i2][j2]) j2 += 1 i2 += 1
def create_boss(ai_settings, screen, aliens, bloods): """创建一个外星boss""" boss = Boss(ai_settings, screen) boss.x = random.randint(100, 500) boss.rect.x = boss.x boss.rect.y = 0 blood = Blood(ai_settings, screen, boss) bloods.add(blood) aliens.add(boss)
def do_task(city, query): boss = Boss(city, query) boss.open_url() lagou = Lagou(city, query) lagou.open_url() zhilian = Zhilian(city, query) zhilian.open_url()
def reset(self): self.boss = Boss() self.rewards = [] self.players = {} self.next_id = 0 self.time = 0.0 self.reset_time = 1e30 for i in range(REWARD_COUNT): self.gen_reward()
def init_game(player_images, ai_images, stage): if stage == 1: # wall group loading map wall_group = load_map_1() elif stage == 2: wall_group = load_map_2() else: wall_group = load_map_3() # ai_tank if stage == 3: ai_number = 1 now_ai_number = 1 ai = BossTank_2(ai_images) ai_group = Group() ai_group.add(ai) else: ai_number = 20 now_ai_number = 3 ai_1 = AiTank(ai_images) ai_2 = AiTank(ai_images) ai_3 = AiTank(ai_images) ai_group = Group() ai_group.add(ai_1) ai_group.add(ai_2) ai_group.add(ai_3) # boss boss = Boss(450, 560) # boss group boss_group = Group() boss_group.add(boss) # player player = Tank(player_images) # player bullet group bullet_group = Group() # ai_tank bullet group ai_bullet_group = Group() # tank group player_group = Group() player_group.add(player) gift_group = Group() tag_point = [(925 + (i % 2) * 25, 100 + (i // 2) * 25) for i in range(ai_number)] return player, boss, player_group, boss_group, ai_group, bullet_group, ai_bullet_group, wall_group,\ gift_group, now_ai_number, tag_point
def __init__(self): self.mrq = MyRedisQueue() self.boss_obj = Boss() self.lagou_obj = Lagou() self.boss_key = 'boss' self.boss_task_level = 2 self.boss_url_level = 1 self.lagou_key = 'lagou' self.lagou_task_level = 2 self.lagou_url_level = 1
def big(): for i in range(1): # This represents a block boss = Boss() # Set a random location for the block boss.rect.x = 1000 boss.rect.y = 350 # Add the block to the list of objects boss_list.add(boss) all_sprites_list.add(boss)
def get_initial_boss_limb_formation(self, boss_img, starting_xcor, starting_ycor): initial_formation = [] for row in range(1): for col in range(1): current_xcor = starting_xcor + col * boss_img.get_width() current_ycor = starting_ycor + row * boss_img.get_height() initial_formation.append( Boss(boss_img, current_xcor, current_ycor)) self.xcor = current_xcor self.ycor = current_ycor return initial_formation
def run_game(): # Initialize pygame, settings, and screen object. pygame.init() pygame.mixer.init() ai_settings = Settings() screen = pygame.display.set_mode( (ai_settings.screen_width, ai_settings.screen_height)) pygame.display.set_caption("Hell") # Set the games frame rate clock = pygame.time.Clock() #set up the sound channels channel1 = pygame.mixer.Channel(0) channel2 = pygame.mixer.Channel(1) shot = pygame.mixer.Sound('sounds/ship_shot.wav') hit = pygame.mixer.Sound('sounds/ship_hit.wav') boss_hit = pygame.mixer.Sound('sounds/boss_hit.wav') # Make a counter for the timed attackes ai_counter = 0 # Make the Play button play_button = Button(ai_settings, screen, "Start") # Make a ship and group of bullets and a group of boss bullets ship = Ship(ai_settings, screen) bullets = Group() boss_bullets = Group() # Make a boss. boss = Boss(ai_settings, screen) # Create an instance to store game statistics and the ui stats = GameStats(ai_settings) ui = Ui(ai_settings, screen, stats) # Start the main loop for the game. while True: gf.check_events(ai_settings, screen, stats, play_button, ship, bullets, shot) if stats.game_active and ai_settings.boss_health > 0: if ai_settings.boss_health == 700 and not ship.second_stage: gf.start_stage2(ai_settings, boss, ship) clock.tick(60) ai_counter = gf.update_counter(ai_counter) gf.update_boss_ai(ai_settings, screen, boss, boss_bullets, ai_counter, ship) ship.update() gf.update_bullets(ai_settings, screen, ship, boss, bullets, boss_hit) gf.update_boss(ai_settings, ai_counter, screen, ship, boss, bullets) gf.update_boss_bullets(ai_settings, stats, screen, ship, boss, bullets, boss_bullets, hit) gf.update_screen(ai_settings, screen, stats, ship, boss, boss_bullets, bullets, play_button, ui)
def init(self): self.camera_pos = 0, 0 self.game_over = False self.display = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) self.surface = pygame.Surface((self.width, self.height)) self.screen_width, self.screen_height = pygame.display.get_surface( ).get_size() self.clock = pygame.time.Clock() self.buildings.clear() self.objects.clear() self.enemies.clear() self.fellows.clear() if self.boss is not None: self.boss.game = None self.boss = None with open('Map/map.txt', 'r') as f: x = 0 y = 0 for line in f.readlines(): for s in line: if s == '#': self.buildings.append(MainBuilding(x, y, self)) if s == '1': self.buildings.append(HighBuilding(x, y, self)) if s == '@': self.buildings.append(GreenBuilding(x, y, self)) if s == 'U': self.buildings.append(UrfuBuilding(x, y, self)) self.boss = Boss(x - 200, y - 200, self) x += Building.size * 2 x = 0 y += Building.size self.player = Player(150, 150, self) self.objects.append(self.player) self.objects.extend(self.buildings) self.keydown_handlers.clear() self.keyup_handlers.clear() self.mouse_handlers.clear() self.player.setup_handlers(self.keydown_handlers, self.keyup_handlers, self.mouse_handlers) for i in range(MAX_ENEMIES_COUNT // 2): self.enemies.append(self.create_hero(Enemy)) for i in range(MAX_ENEMIES_COUNT // 2): self.enemies.append(self.create_hero(ShootingEnemy)) self.objects.append(Citizen(150, 250, self)) for i in range(MAX_CITIZENS_COUNT): self.objects.append(self.create_hero(Citizen)) self.objects.extend(self.enemies) self.player.on_pos_changed = self.change_camera_pos self.ui = lives.Lives(10, 10, self)
def create_monsters(self): monsters = [] boss = Boss() boss.level = self.area_number monsters.append(boss) skeletons = [] number_of_skeletons = randrange(2, 5) for i in range(number_of_skeletons): skeletons.append(Skeleton('Skeleton_' + str(i + 1))) skeletons[0].has_key = True for skeleton in skeletons: skeleton.level = self.area_number monsters.append(skeleton) return monsters
def enter(): import os os.chdir('D:/2016/2d gp/project/image') global nom,be,boss,life,attack,items,item2,back game_framework.reset_time() boss=Boss() nom=Nom() be=load_image("bossba.png") attack = [BossAttack() for i in range(12)] life=Life() items = [attack_item() for i in range(10)] item2=bonus_item() back=load_image("back.png") pass
def enter(): global player,backgrounds,monsters,item_bomb,item_slow,missile,font,boss,font2 global state,Enemy_Missile font = load_font('./Resource/background/ENCR10B.TTF', 20) font2 = load_font('./Resource/background/ENCR10B.TTF', 23) player=aircraft() boss=Boss() backgrounds=Background() monsters = create_monster() item_bomb=Item_bomb() item_slow=Item_slow() game_framework.reset_time() pass
def _create_boss(self): """Создание боса и размещение его в центре.""" count = 1 for point in self.bossstation.turrel_list: if count <= self.stats.level: new_boss = Boss(self) new_boss.x = (point[0] + self.bossstation.rect.x - new_boss.rect.width / 2) new_boss.y = (point[1] + self.bossstation.rect.y - new_boss.rect.height / 2) new_boss.index_in_station = self.bossstation.turrel_list.index( point) self.bosses.add(new_boss) count += 1
def stage_boss(self) -> None: """ Sets up stage two :return: none """ # transition self.transition = arcade.load_texture("images/boss_screen.png") # setting up player self.player = Player(400, 50) # setting up enemies self.enemies_engine = [] self.towers_engine = [] self.enemies = Sprites() self.towers = Sprites() self.obstacles = arcade.SpriteList() self.enemies.append(Minion(400, 400)) self.enemies.append(Minion(400, 400)) self.enemies.append(Minion(400, 400)) self.enemies.append(Minion(400, 400)) self.enemies.append(Minion(400, 400)) self.enemies.append(Minion(400, 400)) self.enemies.append(Minion(400, 400)) self.enemies.append(Minion(400, 400)) self.enemies.append(Boss(400, 400)) for enemy in self.enemies: self.enemies_engine.append( CollisionDetection(enemy, self.obstacles)) self.towers.append(Mage(100, 50, 48, 52)) self.towers.append(Mage(50, 100, 48, 52)) self.towers.append(Mage(700, 750, 48, 52)) self.towers.append(Mage(750, 700, 48, 52)) self.towers.append(Mage(100, 750, 48, 52)) self.towers.append(Mage(50, 700, 48, 52)) self.towers.append(Mage(700, 50, 48, 52)) self.towers.append(Mage(750, 100, 48, 52)) for tower in self.towers: self.towers_engine.append( CollisionDetection(tower.fireball, self.rooms[self.world].wall_list)) self.enemies.append(tower.fireball) for item in self.rooms[self.world].wall_list: self.obstacles.append(item) for item in self.rooms[self.world].traps_list: self.obstacles.append(item) # create engines self.player_engine = CollisionDetection(self.player, self.rooms[self.world].wall_list, self.rooms[self.world].traps_list)
def new(self): ''' Creates sprites ''' self.load_data() for row, tiles in enumerate(self.map_data): for col, tile in enumerate(tiles): if tile == '1': self.walls_sprites.add(Wall(self, col, row)) if tile == 'E': self.enemy_sprites.add(Enemy(self, col, row)) if tile == 'B': self.enemy_sprites.add(Boss(self, col, row)) if tile == 'H': self.hero = Hero(self, col, row) self.all_sprites.add(self.hero)