def reset_game(self, data=None, qr_register=True): #super-class call BaseExhibit.reset_game(self, qr_register=qr_register) self.init_game() #listen once for (any) keyboard event, invoke begin_game when it occurs. Any arguments that #are passed to begin_game are stripped by strip_params decorator self.env.keyboard.listen_once(strip_params(self.begin_game))
def __init__(self, invoker, env, settings): global global_idle global_idle = True BaseExhibit.__init__(self, invoker=invoker, env=env, settings=settings) self.energy_input = EnergyInput(invoker, settings=self.st, env=self.env) self.env.game_load.listen_once(self.mega_reset_game)
def time_out(self): now=time.time() BaseExhibit.__reset__(self) self.seven_flicker(texts=self.score, phormats="%d", lengths=self.env.seven_length, callback=self.reset_game) print(time.time()-now) self.html('html_score') BaseExhibit.end_game(self)
def reset_game(self, qr_register=False): BaseExhibit.reset_game(self, qr_register=qr_register) self.light(0) self.score = 0 self.seven_print(texts=self.score%1000, phormats='%d') self.html('html_instr') self.env.keyboard.listen(self.action_down, key_down) self.env.keyboard.listen(strip_params(self.action_up), key_up)
def end_game(self): BaseExhibit.end_game(self) #logger.info(str(self.user_id)) #self.env.upload_game_results(exponat_name=self.st.exhibit.name, user_id=self.user_id, score=self.score, # level=self.st.level.name, timeout=10) #self.html('html_score') self.seven_flicker(texts=self.score, phormats="%d", lengths=self.env.seven_length, callback=self.reset_game)
def end_game(self): BaseExhibit.__reset__(self) #BaseExhibit.end_game(self) logger.info(str(self.user_id)) self.env.upload_game_results(exponat_name=self.st.exhibit.name, user_id=self.user_id, score=self.score, level=self.st.level.name, timeout=10) self.html('html_score') ## end of BaseExhibit.end_game(self) self.seven_flicker(self.score, "%d", callback=self.reset_game)
def begin_game(self): try: BaseExhibit.begin_game(self) except: pass self.playing = True self.start_time = time.time() self.start_infinite_timer() if self.is_error: self.error_move(1)
def end_game(self): if not self.playing: return self.playing = False if self.infinite_timer is not None: self.infinite_timer.cancel() self.count_score() self.seven_flicker(texts=self.count_score(), phormats="%.1f", end_text='---', callback=self.reset_game) BaseExhibit.end_game(self)
def reset_game(self, data=None): BaseExhibit.reset_game(self) self.init_game() self.sound = None self.end_function = None self.play_tone() self.env.keyboard.find_key(self.st.minus_button).listen( strip_params(self.minus_pressed), key_down) self.env.keyboard.find_key(self.st.plus_button).listen( strip_params(self.plus_pressed), key_down)
def begin_game(self, key, updown): BaseExhibit.begin_game(self) self.run_reset_timer(self.reset_game) for i in range(5): self.change_button() self.update_display(self.st.game_time) self.env.keyboard.listen(self.process_button_press, key_down) self.create_timer( self.st.game_time, self.st.time_tick_interval, callback=self.update_display, end_callback=self.time_out).start()
def begin_game(self): #super-class call BaseExhibit.begin_game(self) #listen to keyboard events, filter key_down events, invoke pressed_button function when #key_down event occurs self.env.keyboard.listen(self.pressed_button, key_down) #create timer that will periodically tick and invoke corresponding callbacks at each tick an #at the end of the process self.create_timer(self.st.game_time, self.st.time_tick_interval, callback=self.time_tick, end_callback=self.time_out).start() #see superclass for documentation self.run_reset_timer(self.reset_game)
def begin_game(self, key, updown): """Starts new game; if first key is baby key, it starts game in the baby mode using only lower 4 keys. """ BaseExhibit.begin_game(self) if key.label in self.st.baby_key_labels: self.is_baby=True self.create_timer(self.st.game_time, self.st.time_tick_interval, callback=self.update_display, end_callback=self.end_game ).start() self.run_reset_timer(self.reset_game) self.move()
def __init__(self, invoker, env, settings): BaseExhibit.__init__(self, invoker, env, settings) self.env.game_load.listen_once(self.reset_game) self.env.game_load.listen_once(self.qr_register) os.system("pkill timidity") os.system("timidity -iA -Os &") alsaseq.client( 'Simple', 1, 1, True ) alsaseq.connectto( 1, 128, 0 ) alsaseq.start() self.st.max_tone_amount = 3 self.tones_amount = 0
def reset_game(self): BaseExhibit.reset_game(self, qr_register=True) self.width = None self.max_width = 0 self.jump_height = None self.max_height = 0 # max_jump_height = self.max_height - self.vertical_base self.max_jump_height = None self.last_jump = 0 self.vertical_base = None self.base_timers = {} self.update_display() self.env.keyboard.listen(self.measure_width, self.width_key_down) self.env.keyboard.listen(self.process_height_button_press, self.height_key_down) self.env.keyboard.listen(self.remove_base_callback, self.height_key_up) self.env.keyboard.listen(self.measure_jump_height, self.jump_key_up)
def reset_game(self, key=None, updown=None): BaseExhibit.reset_game(self) self.env.keyboard.find_key(self.st.start_bl).listen(strip_params(self.begin_game), key_up) self.env.keyboard.find_key(self.st.start_bl).listen(self.reset_game, key_down) self.env.keyboard.find_key(self.st.end_bl).listen(strip_params(self.end_game), key_down) self.env.keyboard.find_key(self.st.error_bl).listen(self.error_down, key_down) self.env.keyboard.find_key(self.st.error_bl).listen(self.error_up, key_up) self.penalty_timer = None self.infinite_timer = None self.playing = False self.score = 0 self.penalty_count = 0 self.last_penalty = -2*self.st.penalty_timeout if not self.is_qr_registered: self.qr_register()
def __init__(self, invoker, env, settings): BaseExhibit.__init__(self, invoker, env, settings) self.env.game_load.listen_once(self.reset_game) self.env.game_load.listen_once(self.qr_register) try: logger.info(os.system("pgrep timidity")) logger.info(os.system("pkill timidity")) logger.info(os.system("timidity -iA -Os -B5,12 &")) #logger.info(os.system("timidity -iA -Os")) time.sleep(2) #essential for good connection alsaseq.client( 'Simple', 1, 1, True ) alsaseq.connectto( 1, 128, 0 ) alsaseq.start() logger.info("timidity is ok. (i hope)") except Exception as e: logger.error("timidity" + str(e)) self.st.max_tone_amount = 3 self.tones_playing = []
def __init__(self, invoker, env, settings): BaseExhibit.__init__(self, invoker=invoker, env=env, settings=settings) self.players = [Player(pio) for pio in self.st.playerIOs] self.env.game_load.listen_once(self.reset_game)
def reset_game(self, data=None, qr_register=True): BaseExhibit.reset_game(self, qr_register=qr_register) self.init_game() self.env.keyboard.listen(self.button_down, key_down)
def reset_game(self): BaseExhibit.reset_game(self, qr_register=True) self.init_game() self.energy_input.remove_callbacks() self.energy_input.listen(self.energy_listener)
def __init__(self, invoker, env, settings): BaseExhibit.__init__(self, invoker=invoker, env=env, settings=settings) self.env.game_load.listen_once(self.reset_game) self.is_error = self.env.keyboard.find_key(self.st.error_bl).pressed
def __init__(self, invoker, env, settings): #call of super-class __init__ BaseExhibit.__init__(self, invoker=invoker, env=env, settings=settings) #when game_load even fires, reset_game is invoked. This happens just once self.env.game_load.listen_once(self.reset_game)
def reset_game(self, data=None): BaseExhibit.reset_game(self) self.init_game() # self.env.keyboard.listen_once(strip_params(self.begin_game)) self.begin_game()
def __init__(self, invoker, env, settings): BaseExhibit.__init__(self, invoker, env, settings) self.env.game_load.listen_once(self.reset_game) self.env.game_load.listen_once(self.qr_register)
def update_display(self, t): BaseExhibit.update_display(self, t) self.seven_print(texts=(t, self.score), phormats=("%.1f", "%d"))
def reset_game(self): BaseExhibit.reset_game(self) for p in self.players: p.score = 0 self.reset_lights() self.env.keyboard.listen_once(strip_params(self.prepare_round), key_down)
def reset_game(self): BaseExhibit.reset_game(self) self.init_game()
def __init__(self, invoker, env, settings): BaseExhibit.__init__(self, invoker=invoker, env=env, settings=settings) logger.info("hura, BaseExhibit.__init__ skoncil.") self.env.game_load.listen_once(self.mega_reset_game)
def reset_game(self): BaseExhibit.reset_game(self, qr_register=True) self.init_game() self.wait_first_move()
def begin_game(self): try: BaseExhibit.begin_game(self) except Exception as e: logger.error(e) self.idle = False
def reset_game(self, qr_register=True): BaseExhibit.reset_game(self, qr_register=qr_register) self.score = 0 self.buttons2timers = {} self.env.keyboard.listen_once(self.begin_game, key_down)