How to use the slider.beatmap.Spinner function in slider

To help you get started, we’ve selected a few slider examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github circleguard / circleguard / circleguard / visualizer / visualizer.py View on Github external
def get_hitobjects(self):
        # get current hitobjects
        current_time = self.clock.get_time()
        found_all = False
        index = 0
        self.hitobjs = []
        while not found_all:
            current_hitobj = self.beatmap.hit_objects[index]
            hit_t = current_hitobj.time.total_seconds() * 1000
            if isinstance(current_hitobj, Slider) or isinstance(current_hitobj, Spinner):
                hit_end = self.get_hit_endtime(current_hitobj) + self.fade_in
            else:
                hit_end = hit_t + self.hitwindow + self.fade_in
            if hit_t - self.preempt < current_time < hit_end:
                self.hitobjs.append(current_hitobj)
            elif hit_t > current_time:
                found_all = True
            if index == len(self.beatmap.hit_objects) - 1:
                found_all = True
            index += 1
github llllllllll / slider / slider / replay.py View on Github external
scores = {"300s": [],
                  "100s": [],
                  "50s": [],
                  "misses": [],
                  "slider_breaks": [],
                  }
        hw = od_to_ms(beatmap.od(easy=self.easy, hard_rock=self.hard_rock))
        rad = circle_radius(
            beatmap.cs(easy=self.easy, hard_rock=self.hard_rock),
        )
        hit_50_threshold = datetime.timedelta(milliseconds=hw.hit_50)
        i = 0
        for obj in beatmap.hit_objects:
            if self.hard_rock:
                obj = obj.hard_rock
            if isinstance(obj, Spinner):
                # spinners are hard
                scores['300s'].append(obj)
                continue
            # we can ignore events before the hit window so iterate
            # until we get past the beginning of the hit window
            while actions[i].offset < obj.time - hit_50_threshold:
                i += 1
            starti = i
            while actions[i].offset < obj.time + hit_50_threshold:
                if (((actions[i].key1 and not actions[i - 1].key1)
                        or (actions[i].key2 and not actions[i - 1].key2))
                        and _within(actions[i].position, obj.position, rad)):
                    # key pressed that wasn't before and
                    # event is in hit window and correct location
                    if isinstance(obj, Circle):
                        _process_circle(obj, actions[i], hw, scores)
github llllllllll / slider / slider / beatmap.py View on Github external
try:
            hitsound = int(hitsound)
        except ValueError:
            raise ValueError(f'hitsound should be an int, got {hitsound!r}')

        if type_ & Circle.type_code:
            parse = Circle._parse
        elif type_ & Slider.type_code:
            parse = partial(
                Slider._parse,
                timing_points=timing_points,
                slider_multiplier=slider_multiplier,
                slider_tick_rate=slider_tick_rate,
            )
        elif type_ & Spinner.type_code:
            parse = Spinner._parse
        elif type_ & HoldNote.type_code:
            parse = HoldNote._parse
        else:
            raise ValueError(f'unknown type code {type_!r}')

        return parse(Position(x, y), time, hitsound, rest)
github llllllllll / slider / slider / beatmap.py View on Github external
def hit_objects_no_spinners(self):
        """The hit objects with spinners filtered out.
        """
        return tuple(e for e in self.hit_objects if not isinstance(e, Spinner))
github circleguard / circleguard / circleguard / visualizer / visualizer.py View on Github external
def draw_hitobject(self, hitobj):
        """
        Calls corresponding functions to draw a Hitobject.

        Args:
            QPainter painter: The painter.
            Hitobj hitobj: A Hitobject.
        """
        if isinstance(hitobj, Circle):
            self.draw_hitcircle(hitobj)
            self.draw_approachcircle(hitobj)
        if isinstance(hitobj, Slider):
            self.draw_slider(hitobj)
        if isinstance(hitobj, Spinner):
            self.draw_spinner(hitobj)
github llllllllll / slider / slider / beatmap.py View on Github external
try:
            hitsound = int(hitsound)
        except ValueError:
            raise ValueError(f'hitsound should be an int, got {hitsound!r}')

        if type_ & Circle.type_code:
            parse = Circle._parse
        elif type_ & Slider.type_code:
            parse = partial(
                Slider._parse,
                timing_points=timing_points,
                slider_multiplier=slider_multiplier,
                slider_tick_rate=slider_tick_rate,
            )
        elif type_ & Spinner.type_code:
            parse = Spinner._parse
        elif type_ & HoldNote.type_code:
            parse = HoldNote._parse
        else:
            raise ValueError(f'unknown type code {type_!r}')

        return parse(Position(x, y), time, hitsound, rest)