コード例 #1
0
ファイル: Level.py プロジェクト: ISNABE/scape-me
    def on_touch_down(self, touch):
        """
        :param touch:
        :rtype: void
        """

        # Reset current path.
        self.player_path = []

        # get if player can draw here
        self.tile_identifier = TouchUtils.get_tile_identifier(self, touch.x, touch.y)
        can_draw = TouchUtils.can_start_stop(self.tile_identifier, self.map_canvas.points)

        if not can_draw:
            self.failed_attempts += 1
            self.canvas.after.clear()
            return

        self.canvas.after.add(
            Point(points=(touch.x, touch.y), texture=self.TRACE_TEXTURE, pointsize=self.touch_width)
        )

        # Save tile.
        self.old_tile_identifier = self.tile_identifier[:]
        self.player_path.append((self.tile_identifier[0], self.tile_identifier[1]))
        self.old_point = (touch.x, touch.y)

        touch.grab(self)
コード例 #2
0
ファイル: Level.py プロジェクト: ISNABE/scape-me
    def on_touch_up(self, touch):
        """
        :param touch:
        :rtype: void
        """

        if touch.grab_current is not self:
            return

        # get if player can draw here
        self.tile_identifier = TouchUtils.get_tile_identifier(self, touch.x, touch.y)
        if self.tile_identifier is None:
            can_draw = False
        else:
            can_draw = TouchUtils.can_start_stop(self.tile_identifier, self.map_canvas.points)

        if can_draw:
            if self.is_path_correct():
                return self.propagate_level_up()

        self.failed_attempts += 1

        # Delete touch if player loose.
        self.canvas.after.clear()
        touch.ungrab(self)
        return