Example #1
0
 def on_mouse_press(self, x, y, button, modifiers):
     x, y = widget.convert_coords(x, y)
     if math.sqrt((x - self.x) ** 2 + (y - self.y) ** 2) <= self.unit.radius:
         self.dragging = True
Example #2
0
 def on_mouse_release(self, x, y, button, modifiers):
     x, y = widget.convert_coords(x, y)
     if self.dragging:
         self.unit.local_angle_target = self.rotation + 90
         self.dragging = False
Example #3
0
 def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
     x, y = widget.convert_coords(x, y)
     if not self.dragging:
         return
     self.rotation = -math.degrees(math.atan2(y - self.y, x - self.x))