def __init__(self, play_mode, sock): self.play_mode = play_mode self.sock = sock self.orientation = sensor.orientation.TOP self.won = False self.elapsed_time = 0.0 self.last_attack = 0.0 self.health = INITIAL_HEALTH self.orientation_history = zeros(HISTORY_SIZE) self.index = 0 self.game_over = False self.quitting = False volume_options = [[u"Volume off", 0], [u"Volume low", 1], [u"Volume med", 2], [u"Volume high", 3]] appuifw.app.exit_key_handler = self.quit appuifw.app.menu = [(u"Choose skin", tuple([(unicode(skin["skinName"].title()), self.skin_changer(skin)) for skin in ui.SKINS])), (u"Set volume", tuple([(option[0], self.volume_changer(option[1])) for option in volume_options])), (u"Back to the fight", self.back_to_fight), (u"Back to main menu", self.quit)] self.__timer = e32.Ao_timer() self.event = None self.eventlock = e32.Ao_lock() axyz.connect(self.new_accel_data) sensor_type = sensor.sensors()['RotSensor'] self.rotation_sensor = sensor.Sensor(sensor_type['id'], sensor_type['category']) self.rotation_sensor.set_event_filter(sensor.RotEventFilter()) self.rotation_sensor.connect(self.new_rotation_data) self.tick()
def __init__(self, play_mode, sock): self.play_mode = play_mode self.sock = sock self.orientation = sensor.orientation.TOP self.won = False self.elapsed_time = 0.0 self.last_attack = 0.0 self.health = INITIAL_HEALTH self.orientation_history = zeros(HISTORY_SIZE) self.index = 0 self.game_over = False self.quitting = False volume_options = [[u"Volume off",0], [u"Volume low",1], [u"Volume med",2], [u"Volume high",3]] appuifw.app.exit_key_handler = self.quit appuifw.app.menu = [ (u"Choose skin", tuple([(unicode(skin["skinName"].title()), self.skin_changer(skin)) for skin in ui.SKINS]) ), (u"Set volume", tuple([(option[0], self.volume_changer(option[1])) for option in volume_options]) ), (u"Back to the fight", self.back_to_fight), (u"Back to main menu", self.quit) ] self.__timer = e32.Ao_timer() self.event = None self.eventlock = e32.Ao_lock() axyz.connect(self.new_accel_data) sensor_type = sensor.sensors()['RotSensor'] self.rotation_sensor = sensor.Sensor(sensor_type['id'], sensor_type['category']) self.rotation_sensor.set_event_filter(sensor.RotEventFilter()) self.rotation_sensor.connect(self.new_rotation_data) self.tick()
def register_accel(self): axyz.connect(e32.ao_callgate(self.printout_))
initialize_game() play_game() except: pass initialize_menu() # Close the connection when we are done connection.close() def menu_message(message): global canvas global img w,h=canvas.size img.clear((0,0,0)) img.blit(backgroundImage, target=(100,0)) img.text ( (10, h/2), unicode(message), fill=(255,255,255), font='dense') canvas.blit(img) # Initialize and start the app print "----------------------------------" # Connect to the accelerometer axyz.connect(read_xyz) backgroundImage=graphics.Image.open('e:\\Python\\pong.png') initialize_menu() appuifw.app.exit_key_handler=handle_quit appuifw.title=u"Pong" app_lock=e32.Ao_lock() app_lock.wait()