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

Hitbox generation doesn't support multiple hitboxes from one texture #2457

Open
Dwang-ML opened this issue Nov 18, 2024 · 1 comment
Open
Milestone

Comments

@Dwang-ML
Copy link
Contributor

Dwang-ML commented Nov 18, 2024

Bug Report

Hitboxes can not be seperated, meaning multiple hitboxes cannot be be generated from one texture.

System Info

Arcade 3.0.0.dev39

vendor: Apple
renderer: Apple M2
version: (4, 1)
python: 3.12.3 (v3.12.3:f6650f9ad7, Apr 9 2024, 08:18:47) [Clang 13.0.0 (clang-1300.0.29.30)]
platform: darwin
pyglet version: 2.1.rc1
PIL version: 11.0.0

Actual behavior:

ML 2024-11-17 at 7 11 22 PM

Let everything in RED be the image and everything that is not red be transparent. If the hitbox is calculated for a png like this, arcade draws the hitbox as shown in blue.

Expected behavior:

ML 2024-11-17 at 7 11 56 PM

Instead of the behavior shown in Actuall behavior, there should be a option to seperate hitboxes as shown in the image above.

Steps to reproduce/example code:

Simply have a png with a few seperate shapes and let arcade calculate the hitbox.

@pushfoo pushfoo added this to the Future milestone Nov 18, 2024
@pushfoo
Copy link
Member

pushfoo commented Nov 18, 2024

TL;DR: Splitting textures into multiple hitboxes seems like a new feature worth considering

To my understanding, Arcade's API assumes the following:

  1. Textures will each have one contiguous sprite element
  2. There will be one contiguous unscaled hitbox per each texture
  3. Sprites have one current texture and one scaled hitbox
  4. Most users will use smaller convex sprites or grid-based games

The last item is important. From what you said on Discord earlier, you had perf drop when using detailed hitboxes:

oh and the fps of the game dropped from 60 -> 30

If the terrain is non-moving, try enabling spatial hashing by passing spatial_hashing=True when creating the terrain list. Since your sprites are large and detailed, you will need to be extra careful about making sure you don't move your sprites. Otherwise, it seems likely you'll have big perf drops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants