def delete(entity): time.sleep(.75) display.clear_text_group('bot_center') #TODO: Let menu take over display.CAMERA['zoom_speed'] = .09 display.CAMERA['next_zoom'] = 4.5 display.CAMERA['camera_move_speed'] = 0.02 #NOTERIETY -= entities.get_entity_group('enemies') events.unregister_event('camera', handle_camera) menu.setup_main_menu() _enemy_amount = len(entities.get_entity_group('enemies')) if _enemy_amount>=3: _loss_string = 'Pirates spread the news of your death...' elif _enemy_amount: _loss_string = 'People think a little less of you now...' else: _loss_string = 'Only the machines saw your death...' display.print_text(display.get_window_size()[0]/2, display.get_window_size()[1]*.25, _loss_string, text_group='bot_center', color=(255, 0, 0, 0), show_for=6, fade_in_speed=4, center=True)
def draw_menu(): _i = 0 display.clear_text_group('menu') for menu_item in MENU: _text = menu_item['text'] if _i == MENU_INDEX: _text = '> '+_text+' <' display.print_text(display.get_window_size()[0]/2, (display.get_window_size()[1]*.65)-(_i*24), _text, show_for=-1, center=True, text_group='menu') _i += 1
def start_arena(weapon=None): display.clear_text_group('menu') display.clear_text_group('logo') display.clear_text_group('bot_center') events.unregister_event('input', control) events.unregister_event('loop', battlefield.loop_attract) events.unregister_event('camera', action_camera) events.register_event('loop', battlefield.loop) battlefield.clean() battlefield.create() display.CAMERA['camera_move_speed'] = 0.05
def start_career(): display.clear_text_group('menu') display.clear_text_group('logo') display.clear_text_group('bot_center') events.unregister_event('input', control) events.unregister_event('loop', battlefield.loop_attract) events.unregister_event('camera', action_camera) events.register_event('loop', levels.loop) battlefield.clean() levels.load_level() display.CAMERA['camera_move_speed'] = 0.05
def spawn_enemies(): global TRANSITION_PAUSE, ANNOUNCE, LEVEL if LEVEL == 5: _boss = ships.create_ivan(x=random.randint(0, worlds.get_size()[0]), y=random.randint(0, worlds.get_size()[1])) _details = [ '<b>Stolovitzky, Ivan</b>', '<i>Suicidal maniac</i>', 'Wanted for: <b>Intergalactic Manslaughter</b>' ] display.camera_zoom(1.5) display.camera_focus_on(_boss['position']) display.clear_text_group('bot_center') display.print_text(display.get_window_size()[0] / 2, display.get_window_size()[1] * .75, 'CRAZY IVAN', font_size=42, text_group='bot_center', center=True, color=(0, 240, 0, 50), fade_in_speed=24, show_for=3) _i = 0 for detail_text in _details: display.print_text(display.get_window_size()[0] * .6, display.get_window_size()[1] * .65 - (24 * _i), detail_text, font_size=20, text_group='bot_center', color=(240, 240, 240, 0), fade_in_speed=(len(_details) - _i) * 2, show_for=3) _i += 1 clock.hang_for(180) entities.register_event(_boss, 'kill', lambda entity: progress.unlock_chaingun()) TRANSITION_PAUSE = 240 ANNOUNCE = True LEVEL += 1 return False if not LEVEL % 4: for i in range(1 * (LEVEL - 1)): ships.create_flea(x=random.randint(0, worlds.get_size()[0]), y=random.randint(0, worlds.get_size()[1])) TRANSITION_PAUSE = 120 ANNOUNCE = True LEVEL += 1 return False for i in range(1 * (LEVEL - 1)): ships.create_flea(x=random.randint(0, worlds.get_size()[0]), y=random.randint(0, worlds.get_size()[1])) _eyemine_spawn_point = (random.randint(worlds.get_size()[0] * .25, worlds.get_size()[0] * .75), random.randint(worlds.get_size()[1] * .25, worlds.get_size()[1] * .75)) for i in range(random.randint(2, 4) * LEVEL): _rand_distance = 350 + (120 * LEVEL) _x_mod = random.randint(-_rand_distance, _rand_distance) _y_mod = random.randint(-_rand_distance, _rand_distance) ships.create_eyemine(x=_eyemine_spawn_point[0] + _x_mod, y=_eyemine_spawn_point[1] + _y_mod) _move = random.randint(0, 1) if _move: _move_direction = random.randint(0, 359) for i in range(random.randint(1, 2) * LEVEL): _x, _y = random.randint(worlds.get_size()[0] * .25, worlds.get_size()[0] * .75), random.randint( worlds.get_size()[1] * .25, worlds.get_size()[1] * .75) _turret = ships.create_missile_turret(x=_x, y=_y) if _move: entities.trigger_event(_turret, 'set_direction', direction=_move_direction) entities.trigger_event(_turret, 'set_minimum_velocity', velocity=[-5, -5]) entities.trigger_event(_turret, 'set_maximum_velocity', velocity=[5, 5]) entities.trigger_event(_turret, 'thrust') if LEVEL >= 3: for i in range(random.randint(1, 2) * (int(round(LEVEL * .25)))): _x, _y = random.randint(worlds.get_size()[0] * .25, worlds.get_size()[0] * .75), random.randint( worlds.get_size()[1] * .25, worlds.get_size()[1] * .75) _turret = ships.create_gun_turret(x=_x, y=_y) if _move: entities.trigger_event(_turret, 'set_direction', direction=_move_direction) entities.trigger_event(_turret, 'set_minimum_velocity', velocity=[-5, -5]) entities.trigger_event(_turret, 'set_maximum_velocity', velocity=[5, 5]) entities.trigger_event(_turret, 'thrust') if 1 * (LEVEL - 1): display.clear_text_group('bot_center') display.print_text(display.get_window_size()[0] / 2, display.get_window_size()[1] * .95, 'ENEMY FIGHTERS INBOUND', color=(0, 240, 0, 255), text_group='bot_center', show_for=1.5, center=True) LEVEL += 1 ANNOUNCE = True TRANSITION_PAUSE = 120
def spawn_enemies(): global TRANSITION_PAUSE, ANNOUNCE, LEVEL if LEVEL == 5: _boss = ships.create_ivan(x=random.randint(0, worlds.get_size()[0]), y=random.randint(0, worlds.get_size()[1])) _details = ['<b>Stolovitzky, Ivan</b>', '<i>Suicidal maniac</i>', 'Wanted for: <b>Intergalactic Manslaughter</b>'] display.camera_zoom(1.5) display.camera_focus_on(_boss['position']) display.clear_text_group('bot_center') display.print_text(display.get_window_size()[0]/2, display.get_window_size()[1]*.75, 'CRAZY IVAN', font_size=42, text_group='bot_center', center=True, color=(0, 240, 0, 50), fade_in_speed=24, show_for=3) _i = 0 for detail_text in _details: display.print_text(display.get_window_size()[0]*.6, display.get_window_size()[1]*.65-(24*_i), detail_text, font_size=20, text_group='bot_center', color=(240, 240, 240, 0), fade_in_speed=(len(_details)-_i)*2, show_for=3) _i += 1 clock.hang_for(180) entities.register_event(_boss, 'kill', lambda entity: progress.unlock_chaingun()) TRANSITION_PAUSE = 240 ANNOUNCE = True LEVEL += 1 return False if not LEVEL % 4: for i in range(1*(LEVEL-1)): ships.create_flea(x=random.randint(0, worlds.get_size()[0]), y=random.randint(0, worlds.get_size()[1])) TRANSITION_PAUSE = 120 ANNOUNCE = True LEVEL += 1 return False for i in range(1*(LEVEL-1)): ships.create_flea(x=random.randint(0, worlds.get_size()[0]), y=random.randint(0, worlds.get_size()[1])) _eyemine_spawn_point = (random.randint(worlds.get_size()[0]*.25, worlds.get_size()[0]*.75), random.randint(worlds.get_size()[1]*.25, worlds.get_size()[1]*.75)) for i in range(random.randint(2, 4)*LEVEL): _rand_distance = 350+(120*LEVEL) _x_mod = random.randint(-_rand_distance, _rand_distance) _y_mod = random.randint(-_rand_distance, _rand_distance) ships.create_eyemine(x=_eyemine_spawn_point[0]+_x_mod, y=_eyemine_spawn_point[1]+_y_mod) _move = random.randint(0, 1) if _move: _move_direction = random.randint(0, 359) for i in range(random.randint(1, 2)*LEVEL): _x, _y = random.randint(worlds.get_size()[0]*.25, worlds.get_size()[0]*.75), random.randint(worlds.get_size()[1]*.25, worlds.get_size()[1]*.75) _turret = ships.create_missile_turret(x=_x, y=_y) if _move: entities.trigger_event(_turret, 'set_direction', direction=_move_direction) entities.trigger_event(_turret, 'set_minimum_velocity', velocity=[-5, -5]) entities.trigger_event(_turret, 'set_maximum_velocity', velocity=[5, 5]) entities.trigger_event(_turret, 'thrust') if LEVEL >= 3: for i in range(random.randint(1, 2)*(int(round(LEVEL*.25)))): _x, _y = random.randint(worlds.get_size()[0]*.25, worlds.get_size()[0]*.75), random.randint(worlds.get_size()[1]*.25, worlds.get_size()[1]*.75) _turret = ships.create_gun_turret(x=_x, y=_y) if _move: entities.trigger_event(_turret, 'set_direction', direction=_move_direction) entities.trigger_event(_turret, 'set_minimum_velocity', velocity=[-5, -5]) entities.trigger_event(_turret, 'set_maximum_velocity', velocity=[5, 5]) entities.trigger_event(_turret, 'thrust') if 1*(LEVEL-1): display.clear_text_group('bot_center') display.print_text(display.get_window_size()[0]/2, display.get_window_size()[1]*.95, 'ENEMY FIGHTERS INBOUND', color=(0, 240, 0, 255), text_group='bot_center', show_for=1.5, center=True) LEVEL += 1 ANNOUNCE = True TRANSITION_PAUSE = 120