Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_sprites_at_point broken #2253

Open
einarf opened this issue Jul 14, 2024 · 4 comments · May be fixed by #2347
Open

get_sprites_at_point broken #2253

einarf opened this issue Jul 14, 2024 · 4 comments · May be fixed by #2347
Assignees
Labels
Milestone

Comments

@einarf
Copy link
Member

einarf commented Jul 14, 2024

When a point intersects a line in the hitbox you get false positives.

EDIT: Changes are already in point-in-polygon-fix branch. Unit tests for the geometry module have been broken up. They needs a bit of extending.

@einarf einarf added the bug label Jul 14, 2024
@einarf einarf added this to the 3.0 mandatory milestone Jul 14, 2024
@einarf
Copy link
Member Author

einarf commented Jul 14, 2024

Poke if you run out of time on this one.

@einarf
Copy link
Member Author

einarf commented Jul 23, 2024

When mouse intersects with the horizontal edges of the hitbox the selection goes crazy including everything to the right.

import arcade
from arcade import SpriteList, Sprite, SpriteSolidColor


class MyGame(arcade.Window):
    def __init__(self):
        super().__init__()

        self.spritelist: SpriteList[Sprite] = arcade.SpriteList()

        for y in range(8):
            for x in range(12):
                sprite = SpriteSolidColor(100, 100, color=arcade.color.WHITE)
                sprite.position = x * 101 + 50, y * 101 + 50
                self.spritelist.append(sprite)

        self.sprite_cursor = arcade.SpriteSolidColor(100, 100, color=arcade.color.WHITE)
        self.pos = 0, 0

    def on_draw(self):
        self.clear()
        # Reset color
        for sprite in self.spritelist:
            sprite.color = arcade.color.WHITE
            # sprite.angle += 0.2

        # Mark hits
        x, y = self.mouse["x"], self.mouse["y"]
        print(x, y)
        hits = arcade.get_sprites_at_point((self.mouse["x"], self.mouse["y"]), self.spritelist)
        for hit in hits:
            hit.color = arcade.color.RED

        self.spritelist.draw()
        self.spritelist.draw_hit_boxes(color=arcade.color.GREEN)


MyGame().run()

@einarf
Copy link
Member Author

einarf commented Jul 23, 2024

from @pushfoo

TL;DR: It's still happening, and it isn't just big sprites

One of our users appears to have run into this on Discord today. Their sprite tiles appear to be 48x48 and the hitbox appears to be clean. See the video below (Converted with ffmepg -i file.avi file.mp4):

777777.mp4

@einarf
Copy link
Member Author

einarf commented Aug 3, 2024

Use point-in-polygon-fix branch

@pushfoo pushfoo linked a pull request Aug 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants