+ def _calc_mouse_pos(self, pos):
+ return (int(pos[0] / TILE_SIZE), int(pos[1] / TILE_SIZE))
+
+ def on_touch_down(self, touch):
+ pos = self._calc_mouse_pos(touch.pos)
+ if pos == self.player.pos:
+ self.mouse_move = True
+ self.mouse_start = pos
+
+ def on_touch_up(self, touch):
+ self.mouse_move = False
+
+ def on_touch_move(self, touch):
+ if self.mouse_move:
+ pos = self._calc_mouse_pos(touch.pos)
+ if (pos[0] - self.mouse_start[0] != 0) or (
+ pos[1] - self.mouse_start[1] != 0):
+ direction = (pos[0] - self.mouse_start[0],
+ pos[1] - self.mouse_start[1])
+ self.do_move(direction)
+ self.mouse_start = pos
+