예제 #1
0
 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))
예제 #2
0
    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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 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)
예제 #7
0
 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)
예제 #8
0
 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)
예제 #9
0
 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)
예제 #10
0
 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()
예제 #11
0
 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)
예제 #12
0
 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()
예제 #13
0
    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
예제 #14
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)
예제 #15
0
    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()
예제 #16
0
    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 = []
예제 #17
0
 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)
예제 #18
0
 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)
예제 #19
0
 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)
예제 #20
0
 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
예제 #21
0
 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)
예제 #22
0
 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()
예제 #23
0
 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)
예제 #24
0
 def update_display(self, t):
     BaseExhibit.update_display(self, t)
     self.seven_print(texts=(t, self.score), phormats=("%.1f", "%d"))
예제 #25
0
 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)
예제 #26
0
 def reset_game(self):
     BaseExhibit.reset_game(self)
     self.init_game()
예제 #27
0
 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)
예제 #28
0
 def reset_game(self):
     BaseExhibit.reset_game(self, qr_register=True)
     self.init_game()
     self.wait_first_move()
예제 #29
0
 def begin_game(self):
     try:
         BaseExhibit.begin_game(self)
     except Exception as e:
         logger.error(e)
     self.idle = False
예제 #30
0
 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)