def shoe_listener(request): x = request['x'] y = request['y'] state = request['state'] if state == 'left-check': client.speak('left') client.left(20) elif state == 'right-check': client.speak('right') client.right(20) client.get_shoe(shoe_listener)
def change_direction(): """turn random.""" status['ready'] = True word = status['word'] if word == 'left': player['direction'] = 'left' elif word == 'right': player['direction'] = 'right' elif word == 'front': player['direction'] = 'front' #elif word == 'back': # player['direction'] = 'back' else: status['ready'] = False if status['ready'] == False: client.speak('"Please say direction, Again"') time.sleep(3) status['name'] = 'game-start' status['word'] = '' game_start() else: status['ready'] = False i = random.randint(1, 3) if i == 1: maid['direction'] = 'left' maid['angle'] = -45 elif i == 2: maid['direction'] = 'right' maid['angle'] = 45 elif i == 3: maid['direction'] = 'front' maid['angle'] = 0 #elif i == 4: # maid['direction'] = 'back' # maid['angle'] = 180 client.left(maid['angle']) if maid['direction'] == 'front': time.sleep(1) else: time.sleep(3) client.right(maid['angle']) if maid['direction'] == 'front': time.sleep(1) else: time.sleep(3) # adjust_face_position() judge_game()
def camera_listener(request): keys = request['faces'].keys() if len(keys) > 0: face = request['faces'][keys[0]] if face['name'] == '': client.speak('"I dont know you"') else: client.speak(face['name']) x = face['x'] if x > 0: client.right(int(30 * x)) time.sleep(2) client.move_acc(int(face['distance'])) else: client.left(int(-30 * x)) time.sleep(2) client.move_acc(int(face['distance'])) client.get_face_positions(camera_listener)
def run(self): flg = True #sound = pygame.mixer.Sound("./sound/tempo_120.wav") tempo = 120.0 / 60 #wf = wave.open('./sound/tempo_120.wav') pygame.mixer.init() pygame.mixer.music.load("./apps/sound/tempo_120.wav") pygame.mixer.music.play(-1) time.sleep(2) #sound.play() for i in range(5): flg = not flg if flg: client.right(30) else: client.left(30) time.sleep(tempo) pygame.mixer.music.stop() time.sleep(1) client.speak('"I am so tired"')
def face_direction(face): x = face['x'] if x > 0: client.right(int(30 * x)) else: client.left(int(-30 * x))