Open einarf opened 1 month ago
Poke if you run out of time on this one.
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()
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
):
https://github.com/pythonarcade/arcade/assets/36696816/d0b054f7-e0f2-41db-a8fe-0aaa704ad62b
Use point-in-polygon-fix
branch
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.