def _mouse_down(self, event): if event.button == InputManager.MOUSE_LEFT: self._mouse_left_is_down = True self._mouse_left_down_pos = event.pos click_event = self.lsclick if self._shift_pushed else self.lclick EventManager.post(click_event, pos=event.pos) elif event.button == InputManager.MOUSE_RIGHT: click_event = self.rsclick if self._shift_pushed else self.rclick EventManager.post(click_event, pos=event.pos)
def _mouse_moved(self, event): pos = event.pos if self._mouse_left_is_down: if self.mouse_dragging: EventManager.post(self.mouse_drag_update, pos=pos) elif InputManager.MOUSE_DRAG_THRESHOLD < \ util.point_dist(self._mouse_left_down_pos, pos): self._mouse_drag_start = pos self.mouse_dragging = True EventManager.post(self.mouse_drag_start, pos=pos) current_active_hotareas = set() for hotarea_id in self._hot_area_ids: if self._hot_area_rects[hotarea_id].collidepoint(pos): current_active_hotareas.add(hotarea_id) entered_hotareas = current_active_hotareas - self._active_hotareas #left_hotareas = self._active_hotareas - current_active_hotareas for hotarea_id in entered_hotareas: callback, args = self._hot_area_actions[hotarea_id] callback(**args)
def _mouse_up(self, event): if event.button == InputManager.MOUSE_LEFT: self._mouse_left_is_down = False if self.mouse_dragging: self.mouse_dragging = False EventManager.post(self.mouse_drag_end) #def _handle_input(self, time_passed): # pressed_keys = pygame.key.get_pressed() # # delta = 0.25 * time_passed # # # camera movement # if pressed_keys[pygame.K_w]: # self._camera.move(0, -delta) # if pressed_keys[pygame.K_s]: # self._camera.move(0, delta) # if pressed_keys[pygame.K_a]: # self._camera.move(-delta, 0) # if pressed_keys[pygame.K_d]: # self._camera.move(delta, 0) # self._camera_moved()
def _post_move_event(self): EventManager.post(self.move_event, cam=self)