def set_objects(self): Builder.load_file("main.kv") self.size = (Window.width, Window.height) self.eyes = Eyes(box=[ self.game_area.x, self.game_area.y + 65, self.game_area.width, self.game_area.height - 175 ]) self.nose = Nose(box=[ self.game_area.x, self.game_area.y + 65, self.game_area.width, self.game_area.height - 175 ]) self.mouth = Mouth(box=[ self.game_area.x, self.game_area.y + 65, self.game_area.width, self.game_area.height - 175 ]) self.game_area.add_widget(self.eyes, index=1) self.eyes.active = True self.game_area.add_widget(self.mouth, index=1) self.mouth.active = True # self.auto_bring_to_front(self.mouth) # nekoja vakva kombinacija da se napravi :) self.game_area.add_widget(self.nose, index=1) self.nose.active = True
def __init__(self, screen): self.targets = [] self.eat_food = [] self.eat_count = 0 self.screen = screen self.shooter = Shooter(self.screen) self.mouth = Mouth(screen) self.total_score = 0 self.final_score = 0 self.eating = False self.chew_timer = 0 self.spawn_count = 0
def __init__(self,resolution,color=(0, 0, 0)): self.screen=pygame.display.set_mode(resolution) self.background = pygame.Surface(self.screen.get_size()) self.background = self.background.convert() self.background.fill(color) center_x=self.background.get_width()/2 self.left_eye=Eye(center_x-250,250) self.right_eye=Eye(center_x+250,250) self.mouth=Mouth(center_x,500) self.photo=Photo() self.draw()
def __init__(self, port=DEFAULT_PORT, logdir='/var/log/xm'): """Creates a new istance of the body. By default it's composed by a thread-safe version of `Legs`, `Mouth` and `Eyes`. Args: port (str): serial port `Legs` will connect to. logdir (str): path where to store logs. """ self.safe_legs = LockAdapter(Legs(port)) eye_log = '{}-eyes.log'.format(str(datetime.date.today())) self.safe_mouth = Mouth() self.safe_eye = Eyes(log=open(os.path.join(logdir, eye_log), 'w')) self.circuits = {} self.add_circuit('forward', target=self.safe_legs.forward, pre=[move_synapse]) self.add_circuit('backward', target=self.safe_legs.backward, pre=[move_synapse]) self.add_circuit('left', target=self.safe_legs.left, pre=[move_synapse]) self.add_circuit('right', target=self.safe_legs.right, pre=[move_synapse]) self.add_circuit('stop', target=self.safe_legs.stop) self.add_circuit('set_speed', target=self.safe_legs.set_speed, pre=[speedvalue_synapse]) self.add_circuit('set_movetime', target=self.safe_legs.set_movetime, pre=[movetime_synapse]) self.add_circuit('say', target=self.safe_mouth.say, pre=[say_synapse]) self.add_circuit('shutup', target=self.safe_mouth.shutup) self.add_circuit('open_eyes', target=self.safe_eye.open) self.add_circuit('close_eyes', target=self.safe_eye.close)
def __init__(self): """default constructor""" super(Brain, self).__init__("brain") self.mouth = Mouth() self.message = "Hello World!"
def __init__(self, bot): if bot: self.mouth = Mouth(bot)
def __init__(self): QWidget.__init__(self) # loaind ui from xml uic.loadUi(os.path.join(DIRPATH, 'app.ui'), self) # FIXME - libpng warning: iCCP: known incorrect sRGB profile self.setWindowIcon(QIcon("./images/robot_icon.png")) # keep the window fixed sized self.setFixedSize(self.size()) # button event handlers self.btnStartCaptureForVideoAnalysis.clicked.connect( self.start_capture_for_video_analysis) self.btnStopCaptureForVideoAnalysis.clicked.connect( self.stop_capture_for_video_analysis) self.btnChooseClassifierXML.clicked.connect( self.choose_classifier_file) self.btnChooseImage.clicked.connect(self.choose_image_for_analysis) self.setup_tray_menu() # add camera ids for i in range(0, 11): self.cboxCameraIds.addItem(str(i)) self.cboxCameraIds1.addItem(str(i)) # setting up handlers for menubar actions self.actionAbout.triggered.connect(self.about) self.actionExit.triggered.connect(qApp.quit) self.actionPreferences.triggered.connect(self.show_preferences) # video analysis image widget self.img_widget_vid_analysis = ImageWidget() self.hlayoutVideoAnalysis.addWidget(self.img_widget_vid_analysis) # face training image widget self.img_widget_face_training = ImageWidget() self.hlayoutFaceTrainingImg.addWidget(self.img_widget_face_training) # face identification image widget self.img_widget_identify_face = ImageWidget() self.hlayoutIdentifyFace.addWidget(self.img_widget_identify_face) # image analysis image widget self.img_widget_img_analysis = ImageWidget() self.hlayoutImageAnalysis.addWidget(self.img_widget_img_analysis) img = cv2.imread("images/human.png") self.img_widget_img_analysis.handle_image_data(img) self.vid_capture = VideoCapture() self.vid_capture.got_image_data_from_camera.connect( self.process_image_data_from_camera) self.highlight_faces = self.chkHighlightFaces.isChecked() self.chkHighlightFaces.stateChanged.connect( self.highlight_faces_checkbox_changed) self.chckGrayscale.stateChanged.connect( self.grayscale_checkbox_changed) # face trainer dataset browser btn handler self.btnBrowseDatasetForFaceTrainer.clicked.connect( self.browse_dataset_for_face_trainer) self.btnBrowseClassifierForFaceTrainer.clicked.connect( self.browse_classifier_file_for_face_trainer) self.btnStartFaceTrainer.clicked.connect(self.start_face_trainer) self.btnBrowseIdentifyFace.clicked.connect(self.browse_identify_face) self.btnTalk.clicked.connect(self.lets_talk) # create and start robot self.robot = Robot(self.lblRobot) self.mouth = Mouth() # connect global signals to slots g_emitter().feed_mouth.connect(self.mouth.feed_text) g_emitter().set_speaking_state.connect(self.robot.set_speaking_state) g_emitter().set_idle_state.connect(self.robot.set_idle_state) self.robot.start() self.mouth.start()
def handle(clock, event_handler): #print('Mode: Demo') # Make the bugs (not too close to center) bugs = [] for _ in range(16): while True: cx = random.randint(0, 19) cy = random.randint(0, 15) if (cx >= 6 and cx < 14) and (cy >= 6 and cy < 14): continue break bugs.append(Bug(cx * 4 + 25, cy * 4 + 17, random.randint(0, 3))) pic = Frame() # Draw the bugs mega = Maze(20, 16, 192) mode_game.draw_maze(mega._maze, pic) # Draw the big bugs bugimage = GR.BIG_BUG pic.draw_image(3, 32, bugimage['standing']) pic.draw_image(108, 32, bugimage['standing']) # The mouth mouth = Mouth(25 + 10 * 4, 17 + 8 * 4, random.randint(0, 3)) # Don't start on a dot pic.set_pixel(mouth.x, mouth.y, 0) hs = str(mode_game.HIGH_SCORE).rjust(4, '0') text.draw_text(pic, 19, 4, 'High Score ' + hs, GR.COLOR_SCORE) text.draw_text(pic, 26, 84, 'Play Giga-Bug', GR.COLOR_SCORE) transitions.wipe_in(pic) """ base_frame = Frame() base_frame.draw_image(10,15, GR.CHARS['A']) # The letter 'A' base_frame.draw_text(5,5, GR.CHARS,'Demonstration') base_frame.draw_image(20,25, GR.BIG_BUG['standing']) # Bug standing base_frame.draw_image(50,25, GR.BIG_BUG['dancing'][0]) # Bug dancing ... base_frame.draw_image(70,25, GR.BIG_BUG['dancing'][1]) # ... two animations direction = 1 # 0=UP, 1=RIGHT, 2=DOWN, 3=LEFT animation = 0 # 0 or 1 ... two animations while True: frame = Frame(base_frame) frame.draw_image(10,60, GR.MOUTH[direction][animation]) hardware.render_frame(frame) animation = (animation + 1) % 2 time.sleep(0.25) """ clock.tick(0.75) nf = MAG.draw_magnifier(pic, mouth.x - 8, mouth.y - 8, 17) MAG.draw_mouth_on_magnifier(nf, mouth) hardware.render_frame(nf) clock.tick(0.75) # Play this setup return play_game(clock, pic, mouth, bugs, event_handler)