def _clean(): events.trigger_event('unload') events.trigger_event('cleanup') events.trigger_event('post_unload') events.unregister_all_events('unload') events.register_event('unload', display.clear_screen)
def boot(window): global KEYS_HELD KEYS_HELD = key.KeyStateHandler() window.push_handlers(KEYS_HELD) events.register_event('input', system_input)
def boot(): if RABBYT: lib2d.init() set_fps(FPS) set_tps(TPS) events.register_event('loop', loop) pyglet.font.add_file('thin_design.ttf')
def create_player(): _player = ships.create_energy_ship() _player['player'] = True player.register_entity(_player) events.register_event('input', player.handle_input, _player['_id']) events.register_event('camera', player.handle_camera, _player['_id']) entities.register_event(_player, 'delete', player.delete)
def create_player(x=0, y=0): _player = ships.create_energy_ship(x=x, y=y) _player['player'] = True player.register_entity(_player) events.register_event('input', player.handle_input, _player['_id']) events.register_event('camera', player.handle_camera, _player['_id'], min_zoom=5, max_zoom=14, max_enemy_distance=10000, center_distance=5000) entities.register_event(_player, 'delete', player.delete) entities.register_event(_player, 'hit_edge', lambda entity: entities.trigger_event(entity, 'hit', damage=100)) entities.trigger_event(_player, 'push', velocity=(30, 30))
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 create(world_name, width=4500, height=4500): global ACTIVE_WORLD WORLDS[world_name] = {'size': (width, height), 'last_tick': get_time(), 'next_tick': get_time()+.000001} #if not ACTIVE_WORLD: ACTIVE_WORLD = world_name events.register_event('draw', sprites.draw)
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 register(entity, use_system_event=None, use_entity_event='tick'): entity['timers'] = [] entities.create_event(entity, 'create_timer') entities.create_event(entity, 'clear_timers') entities.register_event(entity, 'create_timer', create_timer) entities.register_event(entity, 'clear_timers', clear_timers) if use_system_event: events.register_event(use_system_event, lambda: tick(entity)) else: entities.register_event(entity, use_entity_event, tick)
def create(): global WAVE_TIMER_MAX, WAVE_TIMER, WAVE, LEVEL LEVEL = 2 WAVE = 1 WAVE_TIMER = 240 WAVE_TIMER_MAX = 30*45 worlds.create('planet', width=12000, height=12000) events.register_event('tick', tick) create_player() display.clear_grid() create_planet()
def boot(): events.register_event('tick', tick) display.print_text(5, 10, 'flagsdev, 2014', fade_in_speed=2, show_for=4) display.print_text(5, 24, '<b>Vector:Kill: Suicide Ships (Prototype)</b>', color=(200, 200, 200, 0), fade_in_speed=4, show_for=5)
def create_player(): _player = ships.create_energy_ship() _player['player'] = True player.register_entity(_player) events.register_event('input', player.handle_input, _player['_id']) events.register_event('camera', player.handle_camera, _player['_id']) entities.register_event(_player, 'score', player.score) entities.register_event(_player, 'delete', player.delete) entities.register_event(_player, 'kill', lambda entity: events.unregister_event('input', player.handle_input)) entities.register_event(_player, 'kill', lambda entity: display.print_text(display.get_window_size()[0]/2, display.get_window_size()[1]*.75, 'Awarded medal:', color=(255, 0, 0, 50), font_size=18, show_for=3.5, fade_in_speed=6, center=True))
def create_player(): _player = ships.create_energy_ship() _player['player'] = True player.register_entity(_player) events.register_event('input', player.handle_input, _player['_id']) events.register_event('camera', player.handle_camera, _player['_id']) entities.register_event(_player, 'score', player.score) entities.register_event(_player, 'delete', player.delete) entities.register_event( _player, 'kill', lambda entity: events.unregister_event('input', player.handle_input)) entities.register_event( _player, 'kill', lambda entity: display.print_text(display.get_window_size()[0] / 2, display.get_window_size()[1] * .75, 'Awarded medal:', color=(255, 0, 0, 50), font_size=18, show_for=3.5, fade_in_speed=6, center=True))
def setup_main_menu(): global MENU events.register_event('input', control) events.register_event('loop', battlefield.loop_attract) events.register_event('camera', action_camera) battlefield.create(player=False) display.create_text_group('logo') display.create_text_group('menu') MENU = [{'text': 'Planet', 'callback': start_planet}, {'text': 'Arena', 'callback': weapon_selection}, {'text': 'Quit', 'callback': shutdown}] display.print_text(display.get_window_size()[0]/2, display.get_window_size()[1]*.8, 'VECTOR:KILL', color=(0, 255, 0, 100), font_name='Thin Design', font_size=42, center=True, show_for=-1, text_group='logo') display.print_text(display.get_window_size()[0]/2, display.get_window_size()[1]*.20, 'Next unlock:', text_group='bot_center', color=(238, 221, 130, 255), show_for=-1, center=True) display.print_text(display.get_window_size()[0]/2, display.get_window_size()[1]*.15, 'Ivan\'s Chaingun', text_group='bot_center', color=(255, 215, 0, 255), show_for=-1, center=True) draw_menu()
def init(debug=False): logger = logging.getLogger() console_formatter = logging.Formatter('[%(levelname)s] %(message)s', datefmt='%H:%M:%S %m/%d/%y') ch = logging.StreamHandler() ch.setFormatter(console_formatter) logger.addHandler(ch) if debug: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) events.register_event('boot', display.boot) events.register_event('boot', entities.boot) events.register_event('boot', clock.boot) events.register_event('boot', controls.boot) events.register_event('unload', display.clear_screen) events.register_event('input', controls.handle_input) events.register_event('loop', clock.tick) events.register_event('shutdown', display.shutdown)
def boot(): events.register_event('cleanup', cleanup) events.register_event('shutdown', shutdown) events.register_event('tick', tick)
def main(): global MAP for x in range(10000/100): for y in range(10000/100): MAP['%s,%s' % (x*100, y*100)] = {'solid': False} events.register_event('boot', display.boot) events.register_event('boot', entities.boot) events.register_event('boot', worlds.create, world_name='game') events.register_event('boot', boot) events.register_event('boot', ui.boot) events.register_event('boot', controls.boot, display.get_window()) events.register_event('load', display.load, level_editor=False) events.register_event('input', commands) events.register_event('loop', controls.loop) events.register_event('logic', worlds.logic) events.register_event('frame', window) events.register_event('shutdown', display.shutdown) events.trigger_event('boot') events.trigger_event('load') if display.RABBYT: while not display.WINDOW.has_exit: display.lib2d.step(pyglet.clock.tick()) display.WINDOW.dispatch_events() display.WINDOW.dispatch_event('on_draw') display.WINDOW.flip() else: while not display.WINDOW.has_exit: events.trigger_event('loop') display.WINDOW.dispatch_events() display.WINDOW.dispatch_event('on_draw') display.WINDOW.flip()
def loop(): global CHANGE_WAVE_FIRE, TRANSITION_PAUSE, CHANGE_WAVE, WAVE_TIMER, LEVEL, WAVE if TRANSITION_PAUSE and CHANGE_WAVE: _player = entities.get_entity(entities.get_entity_group('players')[0]) if not CHANGE_WAVE_FIRE: entities.trigger_event(_player, 'create_timer', time=120, enter_callback=lambda entity: events.unregister_event('input', player.handle_input), callback=lambda entity: entities.trigger_event(entity, 'push', velocity=(6, 6)), exit_callback=lambda entity: display.camera_snap((-4000, -4000)) and entities.trigger_event(entity, 'set_position', x=-4000, y=-4000) and events.register_event('input', player.handle_input, _player['_id']) and create_planet()) LEVEL += 1 _player['NO_BOUNCE'] = True CHANGE_WAVE_FIRE = True if TRANSITION_PAUSE: TRANSITION_PAUSE -= 1 return False if CHANGE_WAVE: WAVE = 1 CHANGE_WAVE = False if not entities.get_entity_group('enemies') and not entities.get_entity_group('hazards') and WAVE_TIMER: WAVE_TIMER -= 4 if entities.get_entity_group('players') and WAVE_TIMER<=0 or (LEVEL == 2 and not entities.get_entity_group('enemies')): spawn_enemies() WAVE_TIMER = WAVE_TIMER_MAX+(60*WAVE)
def boot(): events.register_event("tick", tick) events.register_event("loop", loop) events.register_event("cleanup", cleanup)
def main(): events.register_event("boot", display.boot) events.register_event("boot", entities.boot) events.register_event("boot", controls.boot, display.get_window()) events.register_event("boot", worlds.create, world_name="game") events.register_event("boot", ui.boot) events.register_event("boot", menu.boot) events.register_event("boot", battlefield.boot) events.register_event("boot", clock.boot) events.register_event("load", display.load) events.register_event("load", display.load) events.register_event("load", levels.load) events.register_event("loop", clock.tick) events.register_event("loop", controls.loop) events.register_event("logic", worlds.logic) events.register_event("frame", window) events.register_event("shutdown", display.shutdown) events.trigger_event("boot") events.trigger_event("load") # clock.create_scheduled_event('world_loop', worlds.loop, 1/display.get_tps()) # clock.create_scheduled_event('window_loop', window, 1/10.0) # pyglet.clock.schedule_interval(window, 1/10.0) # pyglet.clock.schedule_interval(worlds.loop, 1/display.get_tps()) if display.RABBYT: while not display.WINDOW.has_exit: display.lib2d.step(pyglet.clock.tick()) display.WINDOW.dispatch_events() display.WINDOW.dispatch_event("on_draw") display.WINDOW.flip() else: # pyglet.app.run() while not display.WINDOW.has_exit: events.trigger_event("loop") display.WINDOW.dispatch_events() display.WINDOW.dispatch_event("on_draw") display.WINDOW.flip()
def boot(): events.register_event("cleanup", cleanup) events.register_event("shutdown", shutdown) events.register_event("tick", tick)